
obj/user/testpteshare:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 9f 01 00 00       	call   8001d0 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800034 <childofspawn>:
	breakpoint();
}

void
childofspawn(void)
{
  800034:	55                   	push   %ebp
  800035:	89 e5                	mov    %esp,%ebp
  800037:	83 ec 18             	sub    $0x18,%esp
	strcpy(VA, msg2);
  80003a:	a1 04 70 80 00       	mov    0x807004,%eax
  80003f:	89 44 24 04          	mov    %eax,0x4(%esp)
  800043:	c7 04 24 00 00 00 a0 	movl   $0xa0000000,(%esp)
  80004a:	e8 7b 09 00 00       	call   8009ca <strcpy>
	exit();
  80004f:	e8 cc 01 00 00       	call   800220 <exit>
}
  800054:	c9                   	leave  
  800055:	c3                   	ret    

00800056 <umain>:

void childofspawn(void);

void
umain(int argc, char **argv)
{
  800056:	55                   	push   %ebp
  800057:	89 e5                	mov    %esp,%ebp
  800059:	53                   	push   %ebx
  80005a:	83 ec 14             	sub    $0x14,%esp
	int r;

    cprintf("Testin: %x\n", sys_getenvid());
  80005d:	e8 57 11 00 00       	call   8011b9 <sys_getenvid>
  800062:	89 44 24 04          	mov    %eax,0x4(%esp)
  800066:	c7 04 24 a0 34 80 00 	movl   $0x8034a0,(%esp)
  80006d:	e8 8f 02 00 00       	call   800301 <cprintf>

	if (argc != 0)
  800072:	83 7d 08 00          	cmpl   $0x0,0x8(%ebp)
  800076:	74 05                	je     80007d <umain+0x27>
		childofspawn();
  800078:	e8 b7 ff ff ff       	call   800034 <childofspawn>

	if ((r = sys_page_alloc(0, VA, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80007d:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  800084:	00 
  800085:	c7 44 24 04 00 00 00 	movl   $0xa0000000,0x4(%esp)
  80008c:	a0 
  80008d:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800094:	e8 8d 10 00 00       	call   801126 <sys_page_alloc>
  800099:	85 c0                	test   %eax,%eax
  80009b:	79 20                	jns    8000bd <umain+0x67>
		panic("sys_page_alloc: %e", r);
  80009d:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8000a1:	c7 44 24 08 ac 34 80 	movl   $0x8034ac,0x8(%esp)
  8000a8:	00 
  8000a9:	c7 44 24 04 15 00 00 	movl   $0x15,0x4(%esp)
  8000b0:	00 
  8000b1:	c7 04 24 bf 34 80 00 	movl   $0x8034bf,(%esp)
  8000b8:	e8 7f 01 00 00       	call   80023c <_panic>

	// check fork
	if ((r = fork()) < 0)
  8000bd:	e8 b0 11 00 00       	call   801272 <fork>
  8000c2:	89 c3                	mov    %eax,%ebx
  8000c4:	85 c0                	test   %eax,%eax
  8000c6:	79 20                	jns    8000e8 <umain+0x92>
		panic("fork: %e", r);
  8000c8:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8000cc:	c7 44 24 08 d3 34 80 	movl   $0x8034d3,0x8(%esp)
  8000d3:	00 
  8000d4:	c7 44 24 04 19 00 00 	movl   $0x19,0x4(%esp)
  8000db:	00 
  8000dc:	c7 04 24 bf 34 80 00 	movl   $0x8034bf,(%esp)
  8000e3:	e8 54 01 00 00       	call   80023c <_panic>
	if (r == 0) {
  8000e8:	85 c0                	test   %eax,%eax
  8000ea:	75 1a                	jne    800106 <umain+0xb0>
		strcpy(VA, msg);
  8000ec:	a1 00 70 80 00       	mov    0x807000,%eax
  8000f1:	89 44 24 04          	mov    %eax,0x4(%esp)
  8000f5:	c7 04 24 00 00 00 a0 	movl   $0xa0000000,(%esp)
  8000fc:	e8 c9 08 00 00       	call   8009ca <strcpy>
		exit();
  800101:	e8 1a 01 00 00       	call   800220 <exit>
	}
	wait(r);
  800106:	89 1c 24             	mov    %ebx,(%esp)
  800109:	e8 46 2d 00 00       	call   802e54 <wait>
	cprintf("fork handles PTE_SHARE %s\n", strcmp(VA, msg) == 0 ? "right" : "wrong");
  80010e:	a1 00 70 80 00       	mov    0x807000,%eax
  800113:	89 44 24 04          	mov    %eax,0x4(%esp)
  800117:	c7 04 24 00 00 00 a0 	movl   $0xa0000000,(%esp)
  80011e:	e8 36 09 00 00       	call   800a59 <strcmp>
  800123:	85 c0                	test   %eax,%eax
  800125:	b8 dc 34 80 00       	mov    $0x8034dc,%eax
  80012a:	ba e2 34 80 00       	mov    $0x8034e2,%edx
  80012f:	0f 44 c2             	cmove  %edx,%eax
  800132:	89 44 24 04          	mov    %eax,0x4(%esp)
  800136:	c7 04 24 e8 34 80 00 	movl   $0x8034e8,(%esp)
  80013d:	e8 bf 01 00 00       	call   800301 <cprintf>

	// check spawn
	if ((r = spawnl("/testpteshare", "testpteshare", "arg", 0)) < 0)
  800142:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  800149:	00 
  80014a:	c7 44 24 08 03 35 80 	movl   $0x803503,0x8(%esp)
  800151:	00 
  800152:	c7 44 24 04 08 35 80 	movl   $0x803508,0x4(%esp)
  800159:	00 
  80015a:	c7 04 24 07 35 80 00 	movl   $0x803507,(%esp)
  800161:	e8 1e 24 00 00       	call   802584 <spawnl>
  800166:	85 c0                	test   %eax,%eax
  800168:	79 20                	jns    80018a <umain+0x134>
		panic("spawn: %e", r);
  80016a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80016e:	c7 44 24 08 15 35 80 	movl   $0x803515,0x8(%esp)
  800175:	00 
  800176:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80017d:	00 
  80017e:	c7 04 24 bf 34 80 00 	movl   $0x8034bf,(%esp)
  800185:	e8 b2 00 00 00       	call   80023c <_panic>
	wait(r);
  80018a:	89 04 24             	mov    %eax,(%esp)
  80018d:	e8 c2 2c 00 00       	call   802e54 <wait>
	cprintf("spawn handles PTE_SHARE %s\n", strcmp(VA, msg2) == 0 ? "right" : "wrong");
  800192:	a1 04 70 80 00       	mov    0x807004,%eax
  800197:	89 44 24 04          	mov    %eax,0x4(%esp)
  80019b:	c7 04 24 00 00 00 a0 	movl   $0xa0000000,(%esp)
  8001a2:	e8 b2 08 00 00       	call   800a59 <strcmp>
  8001a7:	85 c0                	test   %eax,%eax
  8001a9:	b8 dc 34 80 00       	mov    $0x8034dc,%eax
  8001ae:	ba e2 34 80 00       	mov    $0x8034e2,%edx
  8001b3:	0f 44 c2             	cmove  %edx,%eax
  8001b6:	89 44 24 04          	mov    %eax,0x4(%esp)
  8001ba:	c7 04 24 1f 35 80 00 	movl   $0x80351f,(%esp)
  8001c1:	e8 3b 01 00 00       	call   800301 <cprintf>
static __inline uint64_t read_tsc(void) __attribute__((always_inline));

static __inline void
breakpoint(void)
{
	__asm __volatile("int3");
  8001c6:	cc                   	int3   

	breakpoint();
}
  8001c7:	83 c4 14             	add    $0x14,%esp
  8001ca:	5b                   	pop    %ebx
  8001cb:	5d                   	pop    %ebp
  8001cc:	c3                   	ret    
  8001cd:	00 00                	add    %al,(%eax)
	...

008001d0 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  8001d0:	55                   	push   %ebp
  8001d1:	89 e5                	mov    %esp,%ebp
  8001d3:	83 ec 18             	sub    $0x18,%esp
  8001d6:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8001d9:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8001dc:	8b 75 08             	mov    0x8(%ebp),%esi
  8001df:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  8001e2:	e8 d2 0f 00 00       	call   8011b9 <sys_getenvid>
	env = &envs [ENVX(envid)];
  8001e7:	25 ff 03 00 00       	and    $0x3ff,%eax
  8001ec:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8001ef:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  8001f4:	a3 7c 70 80 00       	mov    %eax,0x80707c

	// save the name of the program so that panic() can use it
	if (argc > 0)
  8001f9:	85 f6                	test   %esi,%esi
  8001fb:	7e 07                	jle    800204 <libmain+0x34>
		binaryname = argv[0];
  8001fd:	8b 03                	mov    (%ebx),%eax
  8001ff:	a3 08 70 80 00       	mov    %eax,0x807008

	// call user main routine
	umain(argc, argv);
  800204:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800208:	89 34 24             	mov    %esi,(%esp)
  80020b:	e8 46 fe ff ff       	call   800056 <umain>

	// exit gracefully
	exit();
  800210:	e8 0b 00 00 00       	call   800220 <exit>
}
  800215:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  800218:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80021b:	89 ec                	mov    %ebp,%esp
  80021d:	5d                   	pop    %ebp
  80021e:	c3                   	ret    
	...

00800220 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  800220:	55                   	push   %ebp
  800221:	89 e5                	mov    %esp,%ebp
  800223:	83 ec 18             	sub    $0x18,%esp
	close_all();
  800226:	e8 5e 19 00 00       	call   801b89 <close_all>
	sys_env_destroy(0);
  80022b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800232:	e8 b6 0f 00 00       	call   8011ed <sys_env_destroy>
}
  800237:	c9                   	leave  
  800238:	c3                   	ret    
  800239:	00 00                	add    %al,(%eax)
	...

0080023c <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  80023c:	55                   	push   %ebp
  80023d:	89 e5                	mov    %esp,%ebp
  80023f:	53                   	push   %ebx
  800240:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  800243:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  800246:	a1 80 70 80 00       	mov    0x807080,%eax
  80024b:	85 c0                	test   %eax,%eax
  80024d:	74 10                	je     80025f <_panic+0x23>
		cprintf("%s: ", argv0);
  80024f:	89 44 24 04          	mov    %eax,0x4(%esp)
  800253:	c7 04 24 70 35 80 00 	movl   $0x803570,(%esp)
  80025a:	e8 a2 00 00 00       	call   800301 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  80025f:	8b 45 0c             	mov    0xc(%ebp),%eax
  800262:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800266:	8b 45 08             	mov    0x8(%ebp),%eax
  800269:	89 44 24 08          	mov    %eax,0x8(%esp)
  80026d:	a1 08 70 80 00       	mov    0x807008,%eax
  800272:	89 44 24 04          	mov    %eax,0x4(%esp)
  800276:	c7 04 24 75 35 80 00 	movl   $0x803575,(%esp)
  80027d:	e8 7f 00 00 00       	call   800301 <cprintf>
	vcprintf(fmt, ap);
  800282:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800286:	8b 45 10             	mov    0x10(%ebp),%eax
  800289:	89 04 24             	mov    %eax,(%esp)
  80028c:	e8 0f 00 00 00       	call   8002a0 <vcprintf>
	cprintf("\n");
  800291:	c7 04 24 07 39 80 00 	movl   $0x803907,(%esp)
  800298:	e8 64 00 00 00       	call   800301 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  80029d:	cc                   	int3   
  80029e:	eb fd                	jmp    80029d <_panic+0x61>

008002a0 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  8002a0:	55                   	push   %ebp
  8002a1:	89 e5                	mov    %esp,%ebp
  8002a3:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  8002a9:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  8002b0:	00 00 00 
	b.cnt = 0;
  8002b3:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  8002ba:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  8002bd:	8b 45 0c             	mov    0xc(%ebp),%eax
  8002c0:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8002c4:	8b 45 08             	mov    0x8(%ebp),%eax
  8002c7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8002cb:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  8002d1:	89 44 24 04          	mov    %eax,0x4(%esp)
  8002d5:	c7 04 24 1b 03 80 00 	movl   $0x80031b,(%esp)
  8002dc:	e8 cc 01 00 00       	call   8004ad <vprintfmt>
	sys_cputs(b.buf, b.idx);
  8002e1:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  8002e7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8002eb:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  8002f1:	89 04 24             	mov    %eax,(%esp)
  8002f4:	e8 c7 0a 00 00       	call   800dc0 <sys_cputs>

	return b.cnt;
}
  8002f9:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  8002ff:	c9                   	leave  
  800300:	c3                   	ret    

00800301 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  800301:	55                   	push   %ebp
  800302:	89 e5                	mov    %esp,%ebp
  800304:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  800307:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  80030a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80030e:	8b 45 08             	mov    0x8(%ebp),%eax
  800311:	89 04 24             	mov    %eax,(%esp)
  800314:	e8 87 ff ff ff       	call   8002a0 <vcprintf>
	va_end(ap);

	return cnt;
}
  800319:	c9                   	leave  
  80031a:	c3                   	ret    

0080031b <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  80031b:	55                   	push   %ebp
  80031c:	89 e5                	mov    %esp,%ebp
  80031e:	53                   	push   %ebx
  80031f:	83 ec 14             	sub    $0x14,%esp
  800322:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  800325:	8b 03                	mov    (%ebx),%eax
  800327:	8b 55 08             	mov    0x8(%ebp),%edx
  80032a:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  80032e:	83 c0 01             	add    $0x1,%eax
  800331:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  800333:	3d ff 00 00 00       	cmp    $0xff,%eax
  800338:	75 19                	jne    800353 <putch+0x38>
		sys_cputs(b->buf, b->idx);
  80033a:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  800341:	00 
  800342:	8d 43 08             	lea    0x8(%ebx),%eax
  800345:	89 04 24             	mov    %eax,(%esp)
  800348:	e8 73 0a 00 00       	call   800dc0 <sys_cputs>
		b->idx = 0;
  80034d:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  800353:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  800357:	83 c4 14             	add    $0x14,%esp
  80035a:	5b                   	pop    %ebx
  80035b:	5d                   	pop    %ebp
  80035c:	c3                   	ret    
  80035d:	00 00                	add    %al,(%eax)
	...

00800360 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  800360:	55                   	push   %ebp
  800361:	89 e5                	mov    %esp,%ebp
  800363:	57                   	push   %edi
  800364:	56                   	push   %esi
  800365:	53                   	push   %ebx
  800366:	83 ec 4c             	sub    $0x4c,%esp
  800369:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  80036c:	89 d6                	mov    %edx,%esi
  80036e:	8b 45 08             	mov    0x8(%ebp),%eax
  800371:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800374:	8b 55 0c             	mov    0xc(%ebp),%edx
  800377:	89 55 e0             	mov    %edx,-0x20(%ebp)
  80037a:	8b 45 10             	mov    0x10(%ebp),%eax
  80037d:	8b 5d 14             	mov    0x14(%ebp),%ebx
  800380:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  800383:	89 45 dc             	mov    %eax,-0x24(%ebp)
  800386:	b9 00 00 00 00       	mov    $0x0,%ecx
  80038b:	39 d1                	cmp    %edx,%ecx
  80038d:	72 15                	jb     8003a4 <printnum+0x44>
  80038f:	77 07                	ja     800398 <printnum+0x38>
  800391:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800394:	39 d0                	cmp    %edx,%eax
  800396:	76 0c                	jbe    8003a4 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  800398:	83 eb 01             	sub    $0x1,%ebx
  80039b:	85 db                	test   %ebx,%ebx
  80039d:	8d 76 00             	lea    0x0(%esi),%esi
  8003a0:	7f 61                	jg     800403 <printnum+0xa3>
  8003a2:	eb 70                	jmp    800414 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  8003a4:	89 7c 24 10          	mov    %edi,0x10(%esp)
  8003a8:	83 eb 01             	sub    $0x1,%ebx
  8003ab:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8003af:	89 44 24 08          	mov    %eax,0x8(%esp)
  8003b3:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  8003b7:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  8003bb:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  8003be:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  8003c1:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8003c4:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8003c8:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8003cf:	00 
  8003d0:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8003d3:	89 04 24             	mov    %eax,(%esp)
  8003d6:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8003d9:	89 54 24 04          	mov    %edx,0x4(%esp)
  8003dd:	e8 3e 2e 00 00       	call   803220 <__udivdi3>
  8003e2:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  8003e5:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  8003e8:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8003ec:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8003f0:	89 04 24             	mov    %eax,(%esp)
  8003f3:	89 54 24 04          	mov    %edx,0x4(%esp)
  8003f7:	89 f2                	mov    %esi,%edx
  8003f9:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8003fc:	e8 5f ff ff ff       	call   800360 <printnum>
  800401:	eb 11                	jmp    800414 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  800403:	89 74 24 04          	mov    %esi,0x4(%esp)
  800407:	89 3c 24             	mov    %edi,(%esp)
  80040a:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  80040d:	83 eb 01             	sub    $0x1,%ebx
  800410:	85 db                	test   %ebx,%ebx
  800412:	7f ef                	jg     800403 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  800414:	89 74 24 04          	mov    %esi,0x4(%esp)
  800418:	8b 74 24 04          	mov    0x4(%esp),%esi
  80041c:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80041f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800423:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80042a:	00 
  80042b:	8b 55 d8             	mov    -0x28(%ebp),%edx
  80042e:	89 14 24             	mov    %edx,(%esp)
  800431:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800434:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800438:	e8 13 2f 00 00       	call   803350 <__umoddi3>
  80043d:	89 74 24 04          	mov    %esi,0x4(%esp)
  800441:	0f be 80 91 35 80 00 	movsbl 0x803591(%eax),%eax
  800448:	89 04 24             	mov    %eax,(%esp)
  80044b:	ff 55 e4             	call   *-0x1c(%ebp)
}
  80044e:	83 c4 4c             	add    $0x4c,%esp
  800451:	5b                   	pop    %ebx
  800452:	5e                   	pop    %esi
  800453:	5f                   	pop    %edi
  800454:	5d                   	pop    %ebp
  800455:	c3                   	ret    

00800456 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  800456:	55                   	push   %ebp
  800457:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  800459:	83 fa 01             	cmp    $0x1,%edx
  80045c:	7e 0e                	jle    80046c <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  80045e:	8b 10                	mov    (%eax),%edx
  800460:	8d 4a 08             	lea    0x8(%edx),%ecx
  800463:	89 08                	mov    %ecx,(%eax)
  800465:	8b 02                	mov    (%edx),%eax
  800467:	8b 52 04             	mov    0x4(%edx),%edx
  80046a:	eb 22                	jmp    80048e <getuint+0x38>
	else if (lflag)
  80046c:	85 d2                	test   %edx,%edx
  80046e:	74 10                	je     800480 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  800470:	8b 10                	mov    (%eax),%edx
  800472:	8d 4a 04             	lea    0x4(%edx),%ecx
  800475:	89 08                	mov    %ecx,(%eax)
  800477:	8b 02                	mov    (%edx),%eax
  800479:	ba 00 00 00 00       	mov    $0x0,%edx
  80047e:	eb 0e                	jmp    80048e <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  800480:	8b 10                	mov    (%eax),%edx
  800482:	8d 4a 04             	lea    0x4(%edx),%ecx
  800485:	89 08                	mov    %ecx,(%eax)
  800487:	8b 02                	mov    (%edx),%eax
  800489:	ba 00 00 00 00       	mov    $0x0,%edx
}
  80048e:	5d                   	pop    %ebp
  80048f:	c3                   	ret    

00800490 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  800490:	55                   	push   %ebp
  800491:	89 e5                	mov    %esp,%ebp
  800493:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  800496:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  80049a:	8b 10                	mov    (%eax),%edx
  80049c:	3b 50 04             	cmp    0x4(%eax),%edx
  80049f:	73 0a                	jae    8004ab <sprintputch+0x1b>
		*b->buf++ = ch;
  8004a1:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8004a4:	88 0a                	mov    %cl,(%edx)
  8004a6:	83 c2 01             	add    $0x1,%edx
  8004a9:	89 10                	mov    %edx,(%eax)
}
  8004ab:	5d                   	pop    %ebp
  8004ac:	c3                   	ret    

008004ad <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  8004ad:	55                   	push   %ebp
  8004ae:	89 e5                	mov    %esp,%ebp
  8004b0:	57                   	push   %edi
  8004b1:	56                   	push   %esi
  8004b2:	53                   	push   %ebx
  8004b3:	83 ec 5c             	sub    $0x5c,%esp
  8004b6:	8b 7d 08             	mov    0x8(%ebp),%edi
  8004b9:	8b 75 0c             	mov    0xc(%ebp),%esi
  8004bc:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  8004bf:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  8004c6:	eb 11                	jmp    8004d9 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  8004c8:	85 c0                	test   %eax,%eax
  8004ca:	0f 84 f9 03 00 00    	je     8008c9 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  8004d0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8004d4:	89 04 24             	mov    %eax,(%esp)
  8004d7:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  8004d9:	0f b6 03             	movzbl (%ebx),%eax
  8004dc:	83 c3 01             	add    $0x1,%ebx
  8004df:	83 f8 25             	cmp    $0x25,%eax
  8004e2:	75 e4                	jne    8004c8 <vprintfmt+0x1b>
  8004e4:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  8004e8:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  8004ef:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  8004f6:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  8004fd:	b9 00 00 00 00       	mov    $0x0,%ecx
  800502:	eb 06                	jmp    80050a <vprintfmt+0x5d>
  800504:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  800508:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  80050a:	0f b6 13             	movzbl (%ebx),%edx
  80050d:	0f b6 c2             	movzbl %dl,%eax
  800510:	89 45 e0             	mov    %eax,-0x20(%ebp)
  800513:	8d 43 01             	lea    0x1(%ebx),%eax
  800516:	83 ea 23             	sub    $0x23,%edx
  800519:	80 fa 55             	cmp    $0x55,%dl
  80051c:	0f 87 8a 03 00 00    	ja     8008ac <vprintfmt+0x3ff>
  800522:	0f b6 d2             	movzbl %dl,%edx
  800525:	ff 24 95 e0 36 80 00 	jmp    *0x8036e0(,%edx,4)
  80052c:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  800530:	eb d6                	jmp    800508 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  800532:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800535:	83 ea 30             	sub    $0x30,%edx
  800538:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  80053b:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  80053e:	8d 5a d0             	lea    -0x30(%edx),%ebx
  800541:	83 fb 09             	cmp    $0x9,%ebx
  800544:	77 54                	ja     80059a <vprintfmt+0xed>
  800546:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  800549:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  80054c:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  80054f:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  800552:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  800556:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  800559:	8d 5a d0             	lea    -0x30(%edx),%ebx
  80055c:	83 fb 09             	cmp    $0x9,%ebx
  80055f:	76 eb                	jbe    80054c <vprintfmt+0x9f>
  800561:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  800564:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800567:	eb 31                	jmp    80059a <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  800569:	8b 55 14             	mov    0x14(%ebp),%edx
  80056c:	8d 5a 04             	lea    0x4(%edx),%ebx
  80056f:	89 5d 14             	mov    %ebx,0x14(%ebp)
  800572:	8b 12                	mov    (%edx),%edx
  800574:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  800577:	eb 21                	jmp    80059a <vprintfmt+0xed>

		case '.':
			if (width < 0)
  800579:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80057d:	ba 00 00 00 00       	mov    $0x0,%edx
  800582:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  800586:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800589:	e9 7a ff ff ff       	jmp    800508 <vprintfmt+0x5b>
  80058e:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  800595:	e9 6e ff ff ff       	jmp    800508 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  80059a:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80059e:	0f 89 64 ff ff ff    	jns    800508 <vprintfmt+0x5b>
  8005a4:	8b 55 d0             	mov    -0x30(%ebp),%edx
  8005a7:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8005aa:	8b 55 c8             	mov    -0x38(%ebp),%edx
  8005ad:	89 55 d0             	mov    %edx,-0x30(%ebp)
  8005b0:	e9 53 ff ff ff       	jmp    800508 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  8005b5:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  8005b8:	e9 4b ff ff ff       	jmp    800508 <vprintfmt+0x5b>
  8005bd:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  8005c0:	8b 45 14             	mov    0x14(%ebp),%eax
  8005c3:	8d 50 04             	lea    0x4(%eax),%edx
  8005c6:	89 55 14             	mov    %edx,0x14(%ebp)
  8005c9:	89 74 24 04          	mov    %esi,0x4(%esp)
  8005cd:	8b 00                	mov    (%eax),%eax
  8005cf:	89 04 24             	mov    %eax,(%esp)
  8005d2:	ff d7                	call   *%edi
  8005d4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8005d7:	e9 fd fe ff ff       	jmp    8004d9 <vprintfmt+0x2c>
  8005dc:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  8005df:	8b 45 14             	mov    0x14(%ebp),%eax
  8005e2:	8d 50 04             	lea    0x4(%eax),%edx
  8005e5:	89 55 14             	mov    %edx,0x14(%ebp)
  8005e8:	8b 00                	mov    (%eax),%eax
  8005ea:	89 c2                	mov    %eax,%edx
  8005ec:	c1 fa 1f             	sar    $0x1f,%edx
  8005ef:	31 d0                	xor    %edx,%eax
  8005f1:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8005f3:	83 f8 12             	cmp    $0x12,%eax
  8005f6:	7f 0b                	jg     800603 <vprintfmt+0x156>
  8005f8:	8b 14 85 40 38 80 00 	mov    0x803840(,%eax,4),%edx
  8005ff:	85 d2                	test   %edx,%edx
  800601:	75 20                	jne    800623 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  800603:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800607:	c7 44 24 08 a2 35 80 	movl   $0x8035a2,0x8(%esp)
  80060e:	00 
  80060f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800613:	89 3c 24             	mov    %edi,(%esp)
  800616:	e8 36 03 00 00       	call   800951 <printfmt>
  80061b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  80061e:	e9 b6 fe ff ff       	jmp    8004d9 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  800623:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800627:	c7 44 24 08 54 3b 80 	movl   $0x803b54,0x8(%esp)
  80062e:	00 
  80062f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800633:	89 3c 24             	mov    %edi,(%esp)
  800636:	e8 16 03 00 00       	call   800951 <printfmt>
  80063b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80063e:	e9 96 fe ff ff       	jmp    8004d9 <vprintfmt+0x2c>
  800643:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800646:	89 c3                	mov    %eax,%ebx
  800648:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  80064b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80064e:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  800651:	8b 45 14             	mov    0x14(%ebp),%eax
  800654:	8d 50 04             	lea    0x4(%eax),%edx
  800657:	89 55 14             	mov    %edx,0x14(%ebp)
  80065a:	8b 00                	mov    (%eax),%eax
  80065c:	89 45 e0             	mov    %eax,-0x20(%ebp)
  80065f:	85 c0                	test   %eax,%eax
  800661:	b8 ab 35 80 00       	mov    $0x8035ab,%eax
  800666:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  80066a:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  80066d:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  800671:	7e 06                	jle    800679 <vprintfmt+0x1cc>
  800673:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  800677:	75 13                	jne    80068c <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800679:	8b 55 e0             	mov    -0x20(%ebp),%edx
  80067c:	0f be 02             	movsbl (%edx),%eax
  80067f:	85 c0                	test   %eax,%eax
  800681:	0f 85 9b 00 00 00    	jne    800722 <vprintfmt+0x275>
  800687:	e9 88 00 00 00       	jmp    800714 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80068c:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800690:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800693:	89 0c 24             	mov    %ecx,(%esp)
  800696:	e8 00 03 00 00       	call   80099b <strnlen>
  80069b:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  80069e:	29 c2                	sub    %eax,%edx
  8006a0:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8006a3:	85 d2                	test   %edx,%edx
  8006a5:	7e d2                	jle    800679 <vprintfmt+0x1cc>
					putch(padc, putdat);
  8006a7:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  8006ab:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  8006ae:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  8006b1:	89 d3                	mov    %edx,%ebx
  8006b3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8006b7:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  8006ba:	89 04 24             	mov    %eax,(%esp)
  8006bd:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  8006bf:	83 eb 01             	sub    $0x1,%ebx
  8006c2:	85 db                	test   %ebx,%ebx
  8006c4:	7f ed                	jg     8006b3 <vprintfmt+0x206>
  8006c6:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  8006c9:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  8006d0:	eb a7                	jmp    800679 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  8006d2:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8006d6:	74 1a                	je     8006f2 <vprintfmt+0x245>
  8006d8:	8d 50 e0             	lea    -0x20(%eax),%edx
  8006db:	83 fa 5e             	cmp    $0x5e,%edx
  8006de:	76 12                	jbe    8006f2 <vprintfmt+0x245>
					putch('?', putdat);
  8006e0:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8006e4:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  8006eb:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  8006ee:	66 90                	xchg   %ax,%ax
  8006f0:	eb 0a                	jmp    8006fc <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  8006f2:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8006f6:	89 04 24             	mov    %eax,(%esp)
  8006f9:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8006fc:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  800700:	0f be 03             	movsbl (%ebx),%eax
  800703:	85 c0                	test   %eax,%eax
  800705:	74 05                	je     80070c <vprintfmt+0x25f>
  800707:	83 c3 01             	add    $0x1,%ebx
  80070a:	eb 29                	jmp    800735 <vprintfmt+0x288>
  80070c:	89 fe                	mov    %edi,%esi
  80070e:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800711:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  800714:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  800718:	7f 2e                	jg     800748 <vprintfmt+0x29b>
  80071a:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80071d:	e9 b7 fd ff ff       	jmp    8004d9 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800722:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800725:	83 c2 01             	add    $0x1,%edx
  800728:	89 7d e0             	mov    %edi,-0x20(%ebp)
  80072b:	89 f7                	mov    %esi,%edi
  80072d:	8b 75 d0             	mov    -0x30(%ebp),%esi
  800730:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  800733:	89 d3                	mov    %edx,%ebx
  800735:	85 f6                	test   %esi,%esi
  800737:	78 99                	js     8006d2 <vprintfmt+0x225>
  800739:	83 ee 01             	sub    $0x1,%esi
  80073c:	79 94                	jns    8006d2 <vprintfmt+0x225>
  80073e:	89 fe                	mov    %edi,%esi
  800740:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800743:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  800746:	eb cc                	jmp    800714 <vprintfmt+0x267>
  800748:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  80074b:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  80074e:	89 74 24 04          	mov    %esi,0x4(%esp)
  800752:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  800759:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  80075b:	83 eb 01             	sub    $0x1,%ebx
  80075e:	85 db                	test   %ebx,%ebx
  800760:	7f ec                	jg     80074e <vprintfmt+0x2a1>
  800762:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  800765:	e9 6f fd ff ff       	jmp    8004d9 <vprintfmt+0x2c>
  80076a:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  80076d:	83 f9 01             	cmp    $0x1,%ecx
  800770:	7e 16                	jle    800788 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  800772:	8b 45 14             	mov    0x14(%ebp),%eax
  800775:	8d 50 08             	lea    0x8(%eax),%edx
  800778:	89 55 14             	mov    %edx,0x14(%ebp)
  80077b:	8b 10                	mov    (%eax),%edx
  80077d:	8b 48 04             	mov    0x4(%eax),%ecx
  800780:	89 55 d8             	mov    %edx,-0x28(%ebp)
  800783:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800786:	eb 32                	jmp    8007ba <vprintfmt+0x30d>
	else if (lflag)
  800788:	85 c9                	test   %ecx,%ecx
  80078a:	74 18                	je     8007a4 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  80078c:	8b 45 14             	mov    0x14(%ebp),%eax
  80078f:	8d 50 04             	lea    0x4(%eax),%edx
  800792:	89 55 14             	mov    %edx,0x14(%ebp)
  800795:	8b 00                	mov    (%eax),%eax
  800797:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80079a:	89 c1                	mov    %eax,%ecx
  80079c:	c1 f9 1f             	sar    $0x1f,%ecx
  80079f:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  8007a2:	eb 16                	jmp    8007ba <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  8007a4:	8b 45 14             	mov    0x14(%ebp),%eax
  8007a7:	8d 50 04             	lea    0x4(%eax),%edx
  8007aa:	89 55 14             	mov    %edx,0x14(%ebp)
  8007ad:	8b 00                	mov    (%eax),%eax
  8007af:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8007b2:	89 c2                	mov    %eax,%edx
  8007b4:	c1 fa 1f             	sar    $0x1f,%edx
  8007b7:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  8007ba:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  8007bd:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8007c0:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  8007c5:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  8007c9:	0f 89 9b 00 00 00    	jns    80086a <vprintfmt+0x3bd>
				putch('-', putdat);
  8007cf:	89 74 24 04          	mov    %esi,0x4(%esp)
  8007d3:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  8007da:	ff d7                	call   *%edi
				num = -(long long) num;
  8007dc:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  8007df:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8007e2:	f7 d9                	neg    %ecx
  8007e4:	83 d3 00             	adc    $0x0,%ebx
  8007e7:	f7 db                	neg    %ebx
  8007e9:	b8 0a 00 00 00       	mov    $0xa,%eax
  8007ee:	eb 7a                	jmp    80086a <vprintfmt+0x3bd>
  8007f0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  8007f3:	89 ca                	mov    %ecx,%edx
  8007f5:	8d 45 14             	lea    0x14(%ebp),%eax
  8007f8:	e8 59 fc ff ff       	call   800456 <getuint>
  8007fd:	89 c1                	mov    %eax,%ecx
  8007ff:	89 d3                	mov    %edx,%ebx
  800801:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  800806:	eb 62                	jmp    80086a <vprintfmt+0x3bd>
  800808:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  80080b:	89 ca                	mov    %ecx,%edx
  80080d:	8d 45 14             	lea    0x14(%ebp),%eax
  800810:	e8 41 fc ff ff       	call   800456 <getuint>
  800815:	89 c1                	mov    %eax,%ecx
  800817:	89 d3                	mov    %edx,%ebx
  800819:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  80081e:	eb 4a                	jmp    80086a <vprintfmt+0x3bd>
  800820:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  800823:	89 74 24 04          	mov    %esi,0x4(%esp)
  800827:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  80082e:	ff d7                	call   *%edi
			putch('x', putdat);
  800830:	89 74 24 04          	mov    %esi,0x4(%esp)
  800834:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  80083b:	ff d7                	call   *%edi
			num = (unsigned long long)
  80083d:	8b 45 14             	mov    0x14(%ebp),%eax
  800840:	8d 50 04             	lea    0x4(%eax),%edx
  800843:	89 55 14             	mov    %edx,0x14(%ebp)
  800846:	8b 08                	mov    (%eax),%ecx
  800848:	bb 00 00 00 00       	mov    $0x0,%ebx
  80084d:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  800852:	eb 16                	jmp    80086a <vprintfmt+0x3bd>
  800854:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  800857:	89 ca                	mov    %ecx,%edx
  800859:	8d 45 14             	lea    0x14(%ebp),%eax
  80085c:	e8 f5 fb ff ff       	call   800456 <getuint>
  800861:	89 c1                	mov    %eax,%ecx
  800863:	89 d3                	mov    %edx,%ebx
  800865:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  80086a:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  80086e:	89 54 24 10          	mov    %edx,0x10(%esp)
  800872:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800875:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800879:	89 44 24 08          	mov    %eax,0x8(%esp)
  80087d:	89 0c 24             	mov    %ecx,(%esp)
  800880:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800884:	89 f2                	mov    %esi,%edx
  800886:	89 f8                	mov    %edi,%eax
  800888:	e8 d3 fa ff ff       	call   800360 <printnum>
  80088d:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800890:	e9 44 fc ff ff       	jmp    8004d9 <vprintfmt+0x2c>
  800895:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800898:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  80089b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80089f:	89 14 24             	mov    %edx,(%esp)
  8008a2:	ff d7                	call   *%edi
  8008a4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8008a7:	e9 2d fc ff ff       	jmp    8004d9 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  8008ac:	89 74 24 04          	mov    %esi,0x4(%esp)
  8008b0:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  8008b7:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  8008b9:	8d 43 ff             	lea    -0x1(%ebx),%eax
  8008bc:	80 38 25             	cmpb   $0x25,(%eax)
  8008bf:	0f 84 14 fc ff ff    	je     8004d9 <vprintfmt+0x2c>
  8008c5:	89 c3                	mov    %eax,%ebx
  8008c7:	eb f0                	jmp    8008b9 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  8008c9:	83 c4 5c             	add    $0x5c,%esp
  8008cc:	5b                   	pop    %ebx
  8008cd:	5e                   	pop    %esi
  8008ce:	5f                   	pop    %edi
  8008cf:	5d                   	pop    %ebp
  8008d0:	c3                   	ret    

008008d1 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  8008d1:	55                   	push   %ebp
  8008d2:	89 e5                	mov    %esp,%ebp
  8008d4:	83 ec 28             	sub    $0x28,%esp
  8008d7:	8b 45 08             	mov    0x8(%ebp),%eax
  8008da:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  8008dd:	85 c0                	test   %eax,%eax
  8008df:	74 04                	je     8008e5 <vsnprintf+0x14>
  8008e1:	85 d2                	test   %edx,%edx
  8008e3:	7f 07                	jg     8008ec <vsnprintf+0x1b>
  8008e5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8008ea:	eb 3b                	jmp    800927 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  8008ec:	89 45 ec             	mov    %eax,-0x14(%ebp)
  8008ef:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  8008f3:	89 45 f0             	mov    %eax,-0x10(%ebp)
  8008f6:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  8008fd:	8b 45 14             	mov    0x14(%ebp),%eax
  800900:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800904:	8b 45 10             	mov    0x10(%ebp),%eax
  800907:	89 44 24 08          	mov    %eax,0x8(%esp)
  80090b:	8d 45 ec             	lea    -0x14(%ebp),%eax
  80090e:	89 44 24 04          	mov    %eax,0x4(%esp)
  800912:	c7 04 24 90 04 80 00 	movl   $0x800490,(%esp)
  800919:	e8 8f fb ff ff       	call   8004ad <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  80091e:	8b 45 ec             	mov    -0x14(%ebp),%eax
  800921:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  800924:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  800927:	c9                   	leave  
  800928:	c3                   	ret    

00800929 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  800929:	55                   	push   %ebp
  80092a:	89 e5                	mov    %esp,%ebp
  80092c:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  80092f:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  800932:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800936:	8b 45 10             	mov    0x10(%ebp),%eax
  800939:	89 44 24 08          	mov    %eax,0x8(%esp)
  80093d:	8b 45 0c             	mov    0xc(%ebp),%eax
  800940:	89 44 24 04          	mov    %eax,0x4(%esp)
  800944:	8b 45 08             	mov    0x8(%ebp),%eax
  800947:	89 04 24             	mov    %eax,(%esp)
  80094a:	e8 82 ff ff ff       	call   8008d1 <vsnprintf>
	va_end(ap);

	return rc;
}
  80094f:	c9                   	leave  
  800950:	c3                   	ret    

00800951 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  800951:	55                   	push   %ebp
  800952:	89 e5                	mov    %esp,%ebp
  800954:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  800957:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  80095a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80095e:	8b 45 10             	mov    0x10(%ebp),%eax
  800961:	89 44 24 08          	mov    %eax,0x8(%esp)
  800965:	8b 45 0c             	mov    0xc(%ebp),%eax
  800968:	89 44 24 04          	mov    %eax,0x4(%esp)
  80096c:	8b 45 08             	mov    0x8(%ebp),%eax
  80096f:	89 04 24             	mov    %eax,(%esp)
  800972:	e8 36 fb ff ff       	call   8004ad <vprintfmt>
	va_end(ap);
}
  800977:	c9                   	leave  
  800978:	c3                   	ret    
  800979:	00 00                	add    %al,(%eax)
  80097b:	00 00                	add    %al,(%eax)
  80097d:	00 00                	add    %al,(%eax)
	...

00800980 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800980:	55                   	push   %ebp
  800981:	89 e5                	mov    %esp,%ebp
  800983:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800986:	b8 00 00 00 00       	mov    $0x0,%eax
  80098b:	80 3a 00             	cmpb   $0x0,(%edx)
  80098e:	74 09                	je     800999 <strlen+0x19>
		n++;
  800990:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  800993:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800997:	75 f7                	jne    800990 <strlen+0x10>
		n++;
	return n;
}
  800999:	5d                   	pop    %ebp
  80099a:	c3                   	ret    

0080099b <strnlen>:

int
strnlen(const char *s, size_t size)
{
  80099b:	55                   	push   %ebp
  80099c:	89 e5                	mov    %esp,%ebp
  80099e:	53                   	push   %ebx
  80099f:	8b 5d 08             	mov    0x8(%ebp),%ebx
  8009a2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  8009a5:	85 c9                	test   %ecx,%ecx
  8009a7:	74 19                	je     8009c2 <strnlen+0x27>
  8009a9:	80 3b 00             	cmpb   $0x0,(%ebx)
  8009ac:	74 14                	je     8009c2 <strnlen+0x27>
  8009ae:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  8009b3:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  8009b6:	39 c8                	cmp    %ecx,%eax
  8009b8:	74 0d                	je     8009c7 <strnlen+0x2c>
  8009ba:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  8009be:	75 f3                	jne    8009b3 <strnlen+0x18>
  8009c0:	eb 05                	jmp    8009c7 <strnlen+0x2c>
  8009c2:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  8009c7:	5b                   	pop    %ebx
  8009c8:	5d                   	pop    %ebp
  8009c9:	c3                   	ret    

008009ca <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  8009ca:	55                   	push   %ebp
  8009cb:	89 e5                	mov    %esp,%ebp
  8009cd:	53                   	push   %ebx
  8009ce:	8b 45 08             	mov    0x8(%ebp),%eax
  8009d1:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  8009d4:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  8009d9:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  8009dd:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  8009e0:	83 c2 01             	add    $0x1,%edx
  8009e3:	84 c9                	test   %cl,%cl
  8009e5:	75 f2                	jne    8009d9 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  8009e7:	5b                   	pop    %ebx
  8009e8:	5d                   	pop    %ebp
  8009e9:	c3                   	ret    

008009ea <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  8009ea:	55                   	push   %ebp
  8009eb:	89 e5                	mov    %esp,%ebp
  8009ed:	56                   	push   %esi
  8009ee:	53                   	push   %ebx
  8009ef:	8b 45 08             	mov    0x8(%ebp),%eax
  8009f2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8009f5:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  8009f8:	85 f6                	test   %esi,%esi
  8009fa:	74 18                	je     800a14 <strncpy+0x2a>
  8009fc:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  800a01:	0f b6 1a             	movzbl (%edx),%ebx
  800a04:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  800a07:	80 3a 01             	cmpb   $0x1,(%edx)
  800a0a:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800a0d:	83 c1 01             	add    $0x1,%ecx
  800a10:	39 ce                	cmp    %ecx,%esi
  800a12:	77 ed                	ja     800a01 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  800a14:	5b                   	pop    %ebx
  800a15:	5e                   	pop    %esi
  800a16:	5d                   	pop    %ebp
  800a17:	c3                   	ret    

00800a18 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  800a18:	55                   	push   %ebp
  800a19:	89 e5                	mov    %esp,%ebp
  800a1b:	56                   	push   %esi
  800a1c:	53                   	push   %ebx
  800a1d:	8b 75 08             	mov    0x8(%ebp),%esi
  800a20:	8b 55 0c             	mov    0xc(%ebp),%edx
  800a23:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  800a26:	89 f0                	mov    %esi,%eax
  800a28:	85 c9                	test   %ecx,%ecx
  800a2a:	74 27                	je     800a53 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  800a2c:	83 e9 01             	sub    $0x1,%ecx
  800a2f:	74 1d                	je     800a4e <strlcpy+0x36>
  800a31:	0f b6 1a             	movzbl (%edx),%ebx
  800a34:	84 db                	test   %bl,%bl
  800a36:	74 16                	je     800a4e <strlcpy+0x36>
			*dst++ = *src++;
  800a38:	88 18                	mov    %bl,(%eax)
  800a3a:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800a3d:	83 e9 01             	sub    $0x1,%ecx
  800a40:	74 0e                	je     800a50 <strlcpy+0x38>
			*dst++ = *src++;
  800a42:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800a45:	0f b6 1a             	movzbl (%edx),%ebx
  800a48:	84 db                	test   %bl,%bl
  800a4a:	75 ec                	jne    800a38 <strlcpy+0x20>
  800a4c:	eb 02                	jmp    800a50 <strlcpy+0x38>
  800a4e:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  800a50:	c6 00 00             	movb   $0x0,(%eax)
  800a53:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  800a55:	5b                   	pop    %ebx
  800a56:	5e                   	pop    %esi
  800a57:	5d                   	pop    %ebp
  800a58:	c3                   	ret    

00800a59 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800a59:	55                   	push   %ebp
  800a5a:	89 e5                	mov    %esp,%ebp
  800a5c:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800a5f:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800a62:	0f b6 01             	movzbl (%ecx),%eax
  800a65:	84 c0                	test   %al,%al
  800a67:	74 15                	je     800a7e <strcmp+0x25>
  800a69:	3a 02                	cmp    (%edx),%al
  800a6b:	75 11                	jne    800a7e <strcmp+0x25>
		p++, q++;
  800a6d:	83 c1 01             	add    $0x1,%ecx
  800a70:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800a73:	0f b6 01             	movzbl (%ecx),%eax
  800a76:	84 c0                	test   %al,%al
  800a78:	74 04                	je     800a7e <strcmp+0x25>
  800a7a:	3a 02                	cmp    (%edx),%al
  800a7c:	74 ef                	je     800a6d <strcmp+0x14>
  800a7e:	0f b6 c0             	movzbl %al,%eax
  800a81:	0f b6 12             	movzbl (%edx),%edx
  800a84:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800a86:	5d                   	pop    %ebp
  800a87:	c3                   	ret    

00800a88 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800a88:	55                   	push   %ebp
  800a89:	89 e5                	mov    %esp,%ebp
  800a8b:	53                   	push   %ebx
  800a8c:	8b 55 08             	mov    0x8(%ebp),%edx
  800a8f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800a92:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800a95:	85 c0                	test   %eax,%eax
  800a97:	74 23                	je     800abc <strncmp+0x34>
  800a99:	0f b6 1a             	movzbl (%edx),%ebx
  800a9c:	84 db                	test   %bl,%bl
  800a9e:	74 24                	je     800ac4 <strncmp+0x3c>
  800aa0:	3a 19                	cmp    (%ecx),%bl
  800aa2:	75 20                	jne    800ac4 <strncmp+0x3c>
  800aa4:	83 e8 01             	sub    $0x1,%eax
  800aa7:	74 13                	je     800abc <strncmp+0x34>
		n--, p++, q++;
  800aa9:	83 c2 01             	add    $0x1,%edx
  800aac:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  800aaf:	0f b6 1a             	movzbl (%edx),%ebx
  800ab2:	84 db                	test   %bl,%bl
  800ab4:	74 0e                	je     800ac4 <strncmp+0x3c>
  800ab6:	3a 19                	cmp    (%ecx),%bl
  800ab8:	74 ea                	je     800aa4 <strncmp+0x1c>
  800aba:	eb 08                	jmp    800ac4 <strncmp+0x3c>
  800abc:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800ac1:	5b                   	pop    %ebx
  800ac2:	5d                   	pop    %ebp
  800ac3:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800ac4:	0f b6 02             	movzbl (%edx),%eax
  800ac7:	0f b6 11             	movzbl (%ecx),%edx
  800aca:	29 d0                	sub    %edx,%eax
  800acc:	eb f3                	jmp    800ac1 <strncmp+0x39>

00800ace <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800ace:	55                   	push   %ebp
  800acf:	89 e5                	mov    %esp,%ebp
  800ad1:	8b 45 08             	mov    0x8(%ebp),%eax
  800ad4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800ad8:	0f b6 10             	movzbl (%eax),%edx
  800adb:	84 d2                	test   %dl,%dl
  800add:	74 15                	je     800af4 <strchr+0x26>
		if (*s == c)
  800adf:	38 ca                	cmp    %cl,%dl
  800ae1:	75 07                	jne    800aea <strchr+0x1c>
  800ae3:	eb 14                	jmp    800af9 <strchr+0x2b>
  800ae5:	38 ca                	cmp    %cl,%dl
  800ae7:	90                   	nop
  800ae8:	74 0f                	je     800af9 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  800aea:	83 c0 01             	add    $0x1,%eax
  800aed:	0f b6 10             	movzbl (%eax),%edx
  800af0:	84 d2                	test   %dl,%dl
  800af2:	75 f1                	jne    800ae5 <strchr+0x17>
  800af4:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  800af9:	5d                   	pop    %ebp
  800afa:	c3                   	ret    

00800afb <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800afb:	55                   	push   %ebp
  800afc:	89 e5                	mov    %esp,%ebp
  800afe:	8b 45 08             	mov    0x8(%ebp),%eax
  800b01:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800b05:	0f b6 10             	movzbl (%eax),%edx
  800b08:	84 d2                	test   %dl,%dl
  800b0a:	74 18                	je     800b24 <strfind+0x29>
		if (*s == c)
  800b0c:	38 ca                	cmp    %cl,%dl
  800b0e:	75 0a                	jne    800b1a <strfind+0x1f>
  800b10:	eb 12                	jmp    800b24 <strfind+0x29>
  800b12:	38 ca                	cmp    %cl,%dl
  800b14:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800b18:	74 0a                	je     800b24 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  800b1a:	83 c0 01             	add    $0x1,%eax
  800b1d:	0f b6 10             	movzbl (%eax),%edx
  800b20:	84 d2                	test   %dl,%dl
  800b22:	75 ee                	jne    800b12 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  800b24:	5d                   	pop    %ebp
  800b25:	c3                   	ret    

00800b26 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800b26:	55                   	push   %ebp
  800b27:	89 e5                	mov    %esp,%ebp
  800b29:	83 ec 0c             	sub    $0xc,%esp
  800b2c:	89 1c 24             	mov    %ebx,(%esp)
  800b2f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800b33:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800b37:	8b 7d 08             	mov    0x8(%ebp),%edi
  800b3a:	8b 45 0c             	mov    0xc(%ebp),%eax
  800b3d:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800b40:	85 c9                	test   %ecx,%ecx
  800b42:	74 30                	je     800b74 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800b44:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800b4a:	75 25                	jne    800b71 <memset+0x4b>
  800b4c:	f6 c1 03             	test   $0x3,%cl
  800b4f:	75 20                	jne    800b71 <memset+0x4b>
		c &= 0xFF;
  800b51:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800b54:	89 d3                	mov    %edx,%ebx
  800b56:	c1 e3 08             	shl    $0x8,%ebx
  800b59:	89 d6                	mov    %edx,%esi
  800b5b:	c1 e6 18             	shl    $0x18,%esi
  800b5e:	89 d0                	mov    %edx,%eax
  800b60:	c1 e0 10             	shl    $0x10,%eax
  800b63:	09 f0                	or     %esi,%eax
  800b65:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800b67:	09 d8                	or     %ebx,%eax
  800b69:	c1 e9 02             	shr    $0x2,%ecx
  800b6c:	fc                   	cld    
  800b6d:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800b6f:	eb 03                	jmp    800b74 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800b71:	fc                   	cld    
  800b72:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800b74:	89 f8                	mov    %edi,%eax
  800b76:	8b 1c 24             	mov    (%esp),%ebx
  800b79:	8b 74 24 04          	mov    0x4(%esp),%esi
  800b7d:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800b81:	89 ec                	mov    %ebp,%esp
  800b83:	5d                   	pop    %ebp
  800b84:	c3                   	ret    

00800b85 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800b85:	55                   	push   %ebp
  800b86:	89 e5                	mov    %esp,%ebp
  800b88:	83 ec 08             	sub    $0x8,%esp
  800b8b:	89 34 24             	mov    %esi,(%esp)
  800b8e:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800b92:	8b 45 08             	mov    0x8(%ebp),%eax
  800b95:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800b98:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  800b9b:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  800b9d:	39 c6                	cmp    %eax,%esi
  800b9f:	73 35                	jae    800bd6 <memmove+0x51>
  800ba1:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800ba4:	39 d0                	cmp    %edx,%eax
  800ba6:	73 2e                	jae    800bd6 <memmove+0x51>
		s += n;
		d += n;
  800ba8:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800baa:	f6 c2 03             	test   $0x3,%dl
  800bad:	75 1b                	jne    800bca <memmove+0x45>
  800baf:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800bb5:	75 13                	jne    800bca <memmove+0x45>
  800bb7:	f6 c1 03             	test   $0x3,%cl
  800bba:	75 0e                	jne    800bca <memmove+0x45>
			asm volatile("std; rep movsl\n"
  800bbc:	83 ef 04             	sub    $0x4,%edi
  800bbf:	8d 72 fc             	lea    -0x4(%edx),%esi
  800bc2:	c1 e9 02             	shr    $0x2,%ecx
  800bc5:	fd                   	std    
  800bc6:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800bc8:	eb 09                	jmp    800bd3 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  800bca:	83 ef 01             	sub    $0x1,%edi
  800bcd:	8d 72 ff             	lea    -0x1(%edx),%esi
  800bd0:	fd                   	std    
  800bd1:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800bd3:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800bd4:	eb 20                	jmp    800bf6 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800bd6:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800bdc:	75 15                	jne    800bf3 <memmove+0x6e>
  800bde:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800be4:	75 0d                	jne    800bf3 <memmove+0x6e>
  800be6:	f6 c1 03             	test   $0x3,%cl
  800be9:	75 08                	jne    800bf3 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  800beb:	c1 e9 02             	shr    $0x2,%ecx
  800bee:	fc                   	cld    
  800bef:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800bf1:	eb 03                	jmp    800bf6 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  800bf3:	fc                   	cld    
  800bf4:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800bf6:	8b 34 24             	mov    (%esp),%esi
  800bf9:	8b 7c 24 04          	mov    0x4(%esp),%edi
  800bfd:	89 ec                	mov    %ebp,%esp
  800bff:	5d                   	pop    %ebp
  800c00:	c3                   	ret    

00800c01 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  800c01:	55                   	push   %ebp
  800c02:	89 e5                	mov    %esp,%ebp
  800c04:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800c07:	8b 45 10             	mov    0x10(%ebp),%eax
  800c0a:	89 44 24 08          	mov    %eax,0x8(%esp)
  800c0e:	8b 45 0c             	mov    0xc(%ebp),%eax
  800c11:	89 44 24 04          	mov    %eax,0x4(%esp)
  800c15:	8b 45 08             	mov    0x8(%ebp),%eax
  800c18:	89 04 24             	mov    %eax,(%esp)
  800c1b:	e8 65 ff ff ff       	call   800b85 <memmove>
}
  800c20:	c9                   	leave  
  800c21:	c3                   	ret    

00800c22 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800c22:	55                   	push   %ebp
  800c23:	89 e5                	mov    %esp,%ebp
  800c25:	57                   	push   %edi
  800c26:	56                   	push   %esi
  800c27:	53                   	push   %ebx
  800c28:	8b 75 08             	mov    0x8(%ebp),%esi
  800c2b:	8b 7d 0c             	mov    0xc(%ebp),%edi
  800c2e:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800c31:	85 c9                	test   %ecx,%ecx
  800c33:	74 36                	je     800c6b <memcmp+0x49>
		if (*s1 != *s2)
  800c35:	0f b6 06             	movzbl (%esi),%eax
  800c38:	0f b6 1f             	movzbl (%edi),%ebx
  800c3b:	38 d8                	cmp    %bl,%al
  800c3d:	74 20                	je     800c5f <memcmp+0x3d>
  800c3f:	eb 14                	jmp    800c55 <memcmp+0x33>
  800c41:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  800c46:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  800c4b:	83 c2 01             	add    $0x1,%edx
  800c4e:	83 e9 01             	sub    $0x1,%ecx
  800c51:	38 d8                	cmp    %bl,%al
  800c53:	74 12                	je     800c67 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  800c55:	0f b6 c0             	movzbl %al,%eax
  800c58:	0f b6 db             	movzbl %bl,%ebx
  800c5b:	29 d8                	sub    %ebx,%eax
  800c5d:	eb 11                	jmp    800c70 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800c5f:	83 e9 01             	sub    $0x1,%ecx
  800c62:	ba 00 00 00 00       	mov    $0x0,%edx
  800c67:	85 c9                	test   %ecx,%ecx
  800c69:	75 d6                	jne    800c41 <memcmp+0x1f>
  800c6b:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  800c70:	5b                   	pop    %ebx
  800c71:	5e                   	pop    %esi
  800c72:	5f                   	pop    %edi
  800c73:	5d                   	pop    %ebp
  800c74:	c3                   	ret    

00800c75 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800c75:	55                   	push   %ebp
  800c76:	89 e5                	mov    %esp,%ebp
  800c78:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  800c7b:	89 c2                	mov    %eax,%edx
  800c7d:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800c80:	39 d0                	cmp    %edx,%eax
  800c82:	73 15                	jae    800c99 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  800c84:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  800c88:	38 08                	cmp    %cl,(%eax)
  800c8a:	75 06                	jne    800c92 <memfind+0x1d>
  800c8c:	eb 0b                	jmp    800c99 <memfind+0x24>
  800c8e:	38 08                	cmp    %cl,(%eax)
  800c90:	74 07                	je     800c99 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  800c92:	83 c0 01             	add    $0x1,%eax
  800c95:	39 c2                	cmp    %eax,%edx
  800c97:	77 f5                	ja     800c8e <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  800c99:	5d                   	pop    %ebp
  800c9a:	c3                   	ret    

00800c9b <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800c9b:	55                   	push   %ebp
  800c9c:	89 e5                	mov    %esp,%ebp
  800c9e:	57                   	push   %edi
  800c9f:	56                   	push   %esi
  800ca0:	53                   	push   %ebx
  800ca1:	83 ec 04             	sub    $0x4,%esp
  800ca4:	8b 55 08             	mov    0x8(%ebp),%edx
  800ca7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800caa:	0f b6 02             	movzbl (%edx),%eax
  800cad:	3c 20                	cmp    $0x20,%al
  800caf:	74 04                	je     800cb5 <strtol+0x1a>
  800cb1:	3c 09                	cmp    $0x9,%al
  800cb3:	75 0e                	jne    800cc3 <strtol+0x28>
		s++;
  800cb5:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800cb8:	0f b6 02             	movzbl (%edx),%eax
  800cbb:	3c 20                	cmp    $0x20,%al
  800cbd:	74 f6                	je     800cb5 <strtol+0x1a>
  800cbf:	3c 09                	cmp    $0x9,%al
  800cc1:	74 f2                	je     800cb5 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  800cc3:	3c 2b                	cmp    $0x2b,%al
  800cc5:	75 0c                	jne    800cd3 <strtol+0x38>
		s++;
  800cc7:	83 c2 01             	add    $0x1,%edx
  800cca:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800cd1:	eb 15                	jmp    800ce8 <strtol+0x4d>
	else if (*s == '-')
  800cd3:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800cda:	3c 2d                	cmp    $0x2d,%al
  800cdc:	75 0a                	jne    800ce8 <strtol+0x4d>
		s++, neg = 1;
  800cde:	83 c2 01             	add    $0x1,%edx
  800ce1:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800ce8:	85 db                	test   %ebx,%ebx
  800cea:	0f 94 c0             	sete   %al
  800ced:	74 05                	je     800cf4 <strtol+0x59>
  800cef:	83 fb 10             	cmp    $0x10,%ebx
  800cf2:	75 18                	jne    800d0c <strtol+0x71>
  800cf4:	80 3a 30             	cmpb   $0x30,(%edx)
  800cf7:	75 13                	jne    800d0c <strtol+0x71>
  800cf9:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  800cfd:	8d 76 00             	lea    0x0(%esi),%esi
  800d00:	75 0a                	jne    800d0c <strtol+0x71>
		s += 2, base = 16;
  800d02:	83 c2 02             	add    $0x2,%edx
  800d05:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800d0a:	eb 15                	jmp    800d21 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800d0c:	84 c0                	test   %al,%al
  800d0e:	66 90                	xchg   %ax,%ax
  800d10:	74 0f                	je     800d21 <strtol+0x86>
  800d12:	bb 0a 00 00 00       	mov    $0xa,%ebx
  800d17:	80 3a 30             	cmpb   $0x30,(%edx)
  800d1a:	75 05                	jne    800d21 <strtol+0x86>
		s++, base = 8;
  800d1c:	83 c2 01             	add    $0x1,%edx
  800d1f:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800d21:	b8 00 00 00 00       	mov    $0x0,%eax
  800d26:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  800d28:	0f b6 0a             	movzbl (%edx),%ecx
  800d2b:	89 cf                	mov    %ecx,%edi
  800d2d:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  800d30:	80 fb 09             	cmp    $0x9,%bl
  800d33:	77 08                	ja     800d3d <strtol+0xa2>
			dig = *s - '0';
  800d35:	0f be c9             	movsbl %cl,%ecx
  800d38:	83 e9 30             	sub    $0x30,%ecx
  800d3b:	eb 1e                	jmp    800d5b <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  800d3d:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  800d40:	80 fb 19             	cmp    $0x19,%bl
  800d43:	77 08                	ja     800d4d <strtol+0xb2>
			dig = *s - 'a' + 10;
  800d45:	0f be c9             	movsbl %cl,%ecx
  800d48:	83 e9 57             	sub    $0x57,%ecx
  800d4b:	eb 0e                	jmp    800d5b <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  800d4d:	8d 5f bf             	lea    -0x41(%edi),%ebx
  800d50:	80 fb 19             	cmp    $0x19,%bl
  800d53:	77 15                	ja     800d6a <strtol+0xcf>
			dig = *s - 'A' + 10;
  800d55:	0f be c9             	movsbl %cl,%ecx
  800d58:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  800d5b:	39 f1                	cmp    %esi,%ecx
  800d5d:	7d 0b                	jge    800d6a <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  800d5f:	83 c2 01             	add    $0x1,%edx
  800d62:	0f af c6             	imul   %esi,%eax
  800d65:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  800d68:	eb be                	jmp    800d28 <strtol+0x8d>
  800d6a:	89 c1                	mov    %eax,%ecx

	if (endptr)
  800d6c:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800d70:	74 05                	je     800d77 <strtol+0xdc>
		*endptr = (char *) s;
  800d72:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800d75:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  800d77:	89 ca                	mov    %ecx,%edx
  800d79:	f7 da                	neg    %edx
  800d7b:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  800d7f:	0f 45 c2             	cmovne %edx,%eax
}
  800d82:	83 c4 04             	add    $0x4,%esp
  800d85:	5b                   	pop    %ebx
  800d86:	5e                   	pop    %esi
  800d87:	5f                   	pop    %edi
  800d88:	5d                   	pop    %ebp
  800d89:	c3                   	ret    
	...

00800d8c <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  800d8c:	55                   	push   %ebp
  800d8d:	89 e5                	mov    %esp,%ebp
  800d8f:	83 ec 0c             	sub    $0xc,%esp
  800d92:	89 1c 24             	mov    %ebx,(%esp)
  800d95:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d99:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800d9d:	ba 00 00 00 00       	mov    $0x0,%edx
  800da2:	b8 01 00 00 00       	mov    $0x1,%eax
  800da7:	89 d1                	mov    %edx,%ecx
  800da9:	89 d3                	mov    %edx,%ebx
  800dab:	89 d7                	mov    %edx,%edi
  800dad:	89 d6                	mov    %edx,%esi
  800daf:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800db1:	8b 1c 24             	mov    (%esp),%ebx
  800db4:	8b 74 24 04          	mov    0x4(%esp),%esi
  800db8:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800dbc:	89 ec                	mov    %ebp,%esp
  800dbe:	5d                   	pop    %ebp
  800dbf:	c3                   	ret    

00800dc0 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800dc0:	55                   	push   %ebp
  800dc1:	89 e5                	mov    %esp,%ebp
  800dc3:	83 ec 0c             	sub    $0xc,%esp
  800dc6:	89 1c 24             	mov    %ebx,(%esp)
  800dc9:	89 74 24 04          	mov    %esi,0x4(%esp)
  800dcd:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800dd1:	b8 00 00 00 00       	mov    $0x0,%eax
  800dd6:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800dd9:	8b 55 08             	mov    0x8(%ebp),%edx
  800ddc:	89 c3                	mov    %eax,%ebx
  800dde:	89 c7                	mov    %eax,%edi
  800de0:	89 c6                	mov    %eax,%esi
  800de2:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  800de4:	8b 1c 24             	mov    (%esp),%ebx
  800de7:	8b 74 24 04          	mov    0x4(%esp),%esi
  800deb:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800def:	89 ec                	mov    %ebp,%esp
  800df1:	5d                   	pop    %ebp
  800df2:	c3                   	ret    

00800df3 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  800df3:	55                   	push   %ebp
  800df4:	89 e5                	mov    %esp,%ebp
  800df6:	83 ec 0c             	sub    $0xc,%esp
  800df9:	89 1c 24             	mov    %ebx,(%esp)
  800dfc:	89 74 24 04          	mov    %esi,0x4(%esp)
  800e00:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e04:	bb 00 00 00 00       	mov    $0x0,%ebx
  800e09:	b8 10 00 00 00       	mov    $0x10,%eax
  800e0e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e11:	8b 55 08             	mov    0x8(%ebp),%edx
  800e14:	89 df                	mov    %ebx,%edi
  800e16:	89 de                	mov    %ebx,%esi
  800e18:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800e1a:	8b 1c 24             	mov    (%esp),%ebx
  800e1d:	8b 74 24 04          	mov    0x4(%esp),%esi
  800e21:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800e25:	89 ec                	mov    %ebp,%esp
  800e27:	5d                   	pop    %ebp
  800e28:	c3                   	ret    

00800e29 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  800e29:	55                   	push   %ebp
  800e2a:	89 e5                	mov    %esp,%ebp
  800e2c:	83 ec 0c             	sub    $0xc,%esp
  800e2f:	89 1c 24             	mov    %ebx,(%esp)
  800e32:	89 74 24 04          	mov    %esi,0x4(%esp)
  800e36:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e3a:	bb 00 00 00 00       	mov    $0x0,%ebx
  800e3f:	b8 0f 00 00 00       	mov    $0xf,%eax
  800e44:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e47:	8b 55 08             	mov    0x8(%ebp),%edx
  800e4a:	89 df                	mov    %ebx,%edi
  800e4c:	89 de                	mov    %ebx,%esi
  800e4e:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800e50:	8b 1c 24             	mov    (%esp),%ebx
  800e53:	8b 74 24 04          	mov    0x4(%esp),%esi
  800e57:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800e5b:	89 ec                	mov    %ebp,%esp
  800e5d:	5d                   	pop    %ebp
  800e5e:	c3                   	ret    

00800e5f <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  800e5f:	55                   	push   %ebp
  800e60:	89 e5                	mov    %esp,%ebp
  800e62:	83 ec 0c             	sub    $0xc,%esp
  800e65:	89 1c 24             	mov    %ebx,(%esp)
  800e68:	89 74 24 04          	mov    %esi,0x4(%esp)
  800e6c:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e70:	ba 00 00 00 00       	mov    $0x0,%edx
  800e75:	b8 0e 00 00 00       	mov    $0xe,%eax
  800e7a:	89 d1                	mov    %edx,%ecx
  800e7c:	89 d3                	mov    %edx,%ebx
  800e7e:	89 d7                	mov    %edx,%edi
  800e80:	89 d6                	mov    %edx,%esi
  800e82:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  800e84:	8b 1c 24             	mov    (%esp),%ebx
  800e87:	8b 74 24 04          	mov    0x4(%esp),%esi
  800e8b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800e8f:	89 ec                	mov    %ebp,%esp
  800e91:	5d                   	pop    %ebp
  800e92:	c3                   	ret    

00800e93 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  800e93:	55                   	push   %ebp
  800e94:	89 e5                	mov    %esp,%ebp
  800e96:	83 ec 38             	sub    $0x38,%esp
  800e99:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800e9c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800e9f:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800ea2:	b9 00 00 00 00       	mov    $0x0,%ecx
  800ea7:	b8 0d 00 00 00       	mov    $0xd,%eax
  800eac:	8b 55 08             	mov    0x8(%ebp),%edx
  800eaf:	89 cb                	mov    %ecx,%ebx
  800eb1:	89 cf                	mov    %ecx,%edi
  800eb3:	89 ce                	mov    %ecx,%esi
  800eb5:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800eb7:	85 c0                	test   %eax,%eax
  800eb9:	7e 28                	jle    800ee3 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  800ebb:	89 44 24 10          	mov    %eax,0x10(%esp)
  800ebf:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  800ec6:	00 
  800ec7:	c7 44 24 08 ab 38 80 	movl   $0x8038ab,0x8(%esp)
  800ece:	00 
  800ecf:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800ed6:	00 
  800ed7:	c7 04 24 c8 38 80 00 	movl   $0x8038c8,(%esp)
  800ede:	e8 59 f3 ff ff       	call   80023c <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  800ee3:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800ee6:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800ee9:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800eec:	89 ec                	mov    %ebp,%esp
  800eee:	5d                   	pop    %ebp
  800eef:	c3                   	ret    

00800ef0 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  800ef0:	55                   	push   %ebp
  800ef1:	89 e5                	mov    %esp,%ebp
  800ef3:	83 ec 38             	sub    $0x38,%esp
  800ef6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800ef9:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800efc:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800eff:	be 00 00 00 00       	mov    $0x0,%esi
  800f04:	b8 0c 00 00 00       	mov    $0xc,%eax
  800f09:	8b 7d 14             	mov    0x14(%ebp),%edi
  800f0c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800f0f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f12:	8b 55 08             	mov    0x8(%ebp),%edx
  800f15:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800f17:	85 c0                	test   %eax,%eax
  800f19:	7e 28                	jle    800f43 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  800f1b:	89 44 24 10          	mov    %eax,0x10(%esp)
  800f1f:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  800f26:	00 
  800f27:	c7 44 24 08 ab 38 80 	movl   $0x8038ab,0x8(%esp)
  800f2e:	00 
  800f2f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800f36:	00 
  800f37:	c7 04 24 c8 38 80 00 	movl   $0x8038c8,(%esp)
  800f3e:	e8 f9 f2 ff ff       	call   80023c <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  800f43:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800f46:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800f49:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800f4c:	89 ec                	mov    %ebp,%esp
  800f4e:	5d                   	pop    %ebp
  800f4f:	c3                   	ret    

00800f50 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  800f50:	55                   	push   %ebp
  800f51:	89 e5                	mov    %esp,%ebp
  800f53:	83 ec 38             	sub    $0x38,%esp
  800f56:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800f59:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800f5c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f5f:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f64:	b8 0a 00 00 00       	mov    $0xa,%eax
  800f69:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f6c:	8b 55 08             	mov    0x8(%ebp),%edx
  800f6f:	89 df                	mov    %ebx,%edi
  800f71:	89 de                	mov    %ebx,%esi
  800f73:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800f75:	85 c0                	test   %eax,%eax
  800f77:	7e 28                	jle    800fa1 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800f79:	89 44 24 10          	mov    %eax,0x10(%esp)
  800f7d:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  800f84:	00 
  800f85:	c7 44 24 08 ab 38 80 	movl   $0x8038ab,0x8(%esp)
  800f8c:	00 
  800f8d:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800f94:	00 
  800f95:	c7 04 24 c8 38 80 00 	movl   $0x8038c8,(%esp)
  800f9c:	e8 9b f2 ff ff       	call   80023c <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  800fa1:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800fa4:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800fa7:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800faa:	89 ec                	mov    %ebp,%esp
  800fac:	5d                   	pop    %ebp
  800fad:	c3                   	ret    

00800fae <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  800fae:	55                   	push   %ebp
  800faf:	89 e5                	mov    %esp,%ebp
  800fb1:	83 ec 38             	sub    $0x38,%esp
  800fb4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800fb7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800fba:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800fbd:	bb 00 00 00 00       	mov    $0x0,%ebx
  800fc2:	b8 09 00 00 00       	mov    $0x9,%eax
  800fc7:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800fca:	8b 55 08             	mov    0x8(%ebp),%edx
  800fcd:	89 df                	mov    %ebx,%edi
  800fcf:	89 de                	mov    %ebx,%esi
  800fd1:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800fd3:	85 c0                	test   %eax,%eax
  800fd5:	7e 28                	jle    800fff <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800fd7:	89 44 24 10          	mov    %eax,0x10(%esp)
  800fdb:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  800fe2:	00 
  800fe3:	c7 44 24 08 ab 38 80 	movl   $0x8038ab,0x8(%esp)
  800fea:	00 
  800feb:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800ff2:	00 
  800ff3:	c7 04 24 c8 38 80 00 	movl   $0x8038c8,(%esp)
  800ffa:	e8 3d f2 ff ff       	call   80023c <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  800fff:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801002:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801005:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801008:	89 ec                	mov    %ebp,%esp
  80100a:	5d                   	pop    %ebp
  80100b:	c3                   	ret    

0080100c <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  80100c:	55                   	push   %ebp
  80100d:	89 e5                	mov    %esp,%ebp
  80100f:	83 ec 38             	sub    $0x38,%esp
  801012:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801015:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801018:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80101b:	bb 00 00 00 00       	mov    $0x0,%ebx
  801020:	b8 08 00 00 00       	mov    $0x8,%eax
  801025:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801028:	8b 55 08             	mov    0x8(%ebp),%edx
  80102b:	89 df                	mov    %ebx,%edi
  80102d:	89 de                	mov    %ebx,%esi
  80102f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801031:	85 c0                	test   %eax,%eax
  801033:	7e 28                	jle    80105d <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801035:	89 44 24 10          	mov    %eax,0x10(%esp)
  801039:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  801040:	00 
  801041:	c7 44 24 08 ab 38 80 	movl   $0x8038ab,0x8(%esp)
  801048:	00 
  801049:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801050:	00 
  801051:	c7 04 24 c8 38 80 00 	movl   $0x8038c8,(%esp)
  801058:	e8 df f1 ff ff       	call   80023c <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  80105d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801060:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801063:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801066:	89 ec                	mov    %ebp,%esp
  801068:	5d                   	pop    %ebp
  801069:	c3                   	ret    

0080106a <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  80106a:	55                   	push   %ebp
  80106b:	89 e5                	mov    %esp,%ebp
  80106d:	83 ec 38             	sub    $0x38,%esp
  801070:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801073:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801076:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801079:	bb 00 00 00 00       	mov    $0x0,%ebx
  80107e:	b8 06 00 00 00       	mov    $0x6,%eax
  801083:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801086:	8b 55 08             	mov    0x8(%ebp),%edx
  801089:	89 df                	mov    %ebx,%edi
  80108b:	89 de                	mov    %ebx,%esi
  80108d:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80108f:	85 c0                	test   %eax,%eax
  801091:	7e 28                	jle    8010bb <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801093:	89 44 24 10          	mov    %eax,0x10(%esp)
  801097:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  80109e:	00 
  80109f:	c7 44 24 08 ab 38 80 	movl   $0x8038ab,0x8(%esp)
  8010a6:	00 
  8010a7:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8010ae:	00 
  8010af:	c7 04 24 c8 38 80 00 	movl   $0x8038c8,(%esp)
  8010b6:	e8 81 f1 ff ff       	call   80023c <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  8010bb:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8010be:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8010c1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8010c4:	89 ec                	mov    %ebp,%esp
  8010c6:	5d                   	pop    %ebp
  8010c7:	c3                   	ret    

008010c8 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  8010c8:	55                   	push   %ebp
  8010c9:	89 e5                	mov    %esp,%ebp
  8010cb:	83 ec 38             	sub    $0x38,%esp
  8010ce:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8010d1:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8010d4:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8010d7:	b8 05 00 00 00       	mov    $0x5,%eax
  8010dc:	8b 75 18             	mov    0x18(%ebp),%esi
  8010df:	8b 7d 14             	mov    0x14(%ebp),%edi
  8010e2:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8010e5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8010e8:	8b 55 08             	mov    0x8(%ebp),%edx
  8010eb:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8010ed:	85 c0                	test   %eax,%eax
  8010ef:	7e 28                	jle    801119 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8010f1:	89 44 24 10          	mov    %eax,0x10(%esp)
  8010f5:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  8010fc:	00 
  8010fd:	c7 44 24 08 ab 38 80 	movl   $0x8038ab,0x8(%esp)
  801104:	00 
  801105:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80110c:	00 
  80110d:	c7 04 24 c8 38 80 00 	movl   $0x8038c8,(%esp)
  801114:	e8 23 f1 ff ff       	call   80023c <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  801119:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80111c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80111f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801122:	89 ec                	mov    %ebp,%esp
  801124:	5d                   	pop    %ebp
  801125:	c3                   	ret    

00801126 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  801126:	55                   	push   %ebp
  801127:	89 e5                	mov    %esp,%ebp
  801129:	83 ec 38             	sub    $0x38,%esp
  80112c:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  80112f:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801132:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801135:	be 00 00 00 00       	mov    $0x0,%esi
  80113a:	b8 04 00 00 00       	mov    $0x4,%eax
  80113f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801142:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801145:	8b 55 08             	mov    0x8(%ebp),%edx
  801148:	89 f7                	mov    %esi,%edi
  80114a:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80114c:	85 c0                	test   %eax,%eax
  80114e:	7e 28                	jle    801178 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  801150:	89 44 24 10          	mov    %eax,0x10(%esp)
  801154:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  80115b:	00 
  80115c:	c7 44 24 08 ab 38 80 	movl   $0x8038ab,0x8(%esp)
  801163:	00 
  801164:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80116b:	00 
  80116c:	c7 04 24 c8 38 80 00 	movl   $0x8038c8,(%esp)
  801173:	e8 c4 f0 ff ff       	call   80023c <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  801178:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80117b:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80117e:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801181:	89 ec                	mov    %ebp,%esp
  801183:	5d                   	pop    %ebp
  801184:	c3                   	ret    

00801185 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  801185:	55                   	push   %ebp
  801186:	89 e5                	mov    %esp,%ebp
  801188:	83 ec 0c             	sub    $0xc,%esp
  80118b:	89 1c 24             	mov    %ebx,(%esp)
  80118e:	89 74 24 04          	mov    %esi,0x4(%esp)
  801192:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801196:	ba 00 00 00 00       	mov    $0x0,%edx
  80119b:	b8 0b 00 00 00       	mov    $0xb,%eax
  8011a0:	89 d1                	mov    %edx,%ecx
  8011a2:	89 d3                	mov    %edx,%ebx
  8011a4:	89 d7                	mov    %edx,%edi
  8011a6:	89 d6                	mov    %edx,%esi
  8011a8:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  8011aa:	8b 1c 24             	mov    (%esp),%ebx
  8011ad:	8b 74 24 04          	mov    0x4(%esp),%esi
  8011b1:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8011b5:	89 ec                	mov    %ebp,%esp
  8011b7:	5d                   	pop    %ebp
  8011b8:	c3                   	ret    

008011b9 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  8011b9:	55                   	push   %ebp
  8011ba:	89 e5                	mov    %esp,%ebp
  8011bc:	83 ec 0c             	sub    $0xc,%esp
  8011bf:	89 1c 24             	mov    %ebx,(%esp)
  8011c2:	89 74 24 04          	mov    %esi,0x4(%esp)
  8011c6:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8011ca:	ba 00 00 00 00       	mov    $0x0,%edx
  8011cf:	b8 02 00 00 00       	mov    $0x2,%eax
  8011d4:	89 d1                	mov    %edx,%ecx
  8011d6:	89 d3                	mov    %edx,%ebx
  8011d8:	89 d7                	mov    %edx,%edi
  8011da:	89 d6                	mov    %edx,%esi
  8011dc:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  8011de:	8b 1c 24             	mov    (%esp),%ebx
  8011e1:	8b 74 24 04          	mov    0x4(%esp),%esi
  8011e5:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8011e9:	89 ec                	mov    %ebp,%esp
  8011eb:	5d                   	pop    %ebp
  8011ec:	c3                   	ret    

008011ed <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  8011ed:	55                   	push   %ebp
  8011ee:	89 e5                	mov    %esp,%ebp
  8011f0:	83 ec 38             	sub    $0x38,%esp
  8011f3:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8011f6:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8011f9:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8011fc:	b9 00 00 00 00       	mov    $0x0,%ecx
  801201:	b8 03 00 00 00       	mov    $0x3,%eax
  801206:	8b 55 08             	mov    0x8(%ebp),%edx
  801209:	89 cb                	mov    %ecx,%ebx
  80120b:	89 cf                	mov    %ecx,%edi
  80120d:	89 ce                	mov    %ecx,%esi
  80120f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801211:	85 c0                	test   %eax,%eax
  801213:	7e 28                	jle    80123d <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  801215:	89 44 24 10          	mov    %eax,0x10(%esp)
  801219:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  801220:	00 
  801221:	c7 44 24 08 ab 38 80 	movl   $0x8038ab,0x8(%esp)
  801228:	00 
  801229:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801230:	00 
  801231:	c7 04 24 c8 38 80 00 	movl   $0x8038c8,(%esp)
  801238:	e8 ff ef ff ff       	call   80023c <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  80123d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801240:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801243:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801246:	89 ec                	mov    %ebp,%esp
  801248:	5d                   	pop    %ebp
  801249:	c3                   	ret    
  80124a:	00 00                	add    %al,(%eax)
  80124c:	00 00                	add    %al,(%eax)
	...

00801250 <sfork>:
}

// Challenge!
int
sfork(void)
{
  801250:	55                   	push   %ebp
  801251:	89 e5                	mov    %esp,%ebp
  801253:	83 ec 18             	sub    $0x18,%esp
	panic("sfork not implemented");
  801256:	c7 44 24 08 d6 38 80 	movl   $0x8038d6,0x8(%esp)
  80125d:	00 
  80125e:	c7 44 24 04 9a 00 00 	movl   $0x9a,0x4(%esp)
  801265:	00 
  801266:	c7 04 24 ec 38 80 00 	movl   $0x8038ec,(%esp)
  80126d:	e8 ca ef ff ff       	call   80023c <_panic>

00801272 <fork>:
//   Neither user exception stack should ever be marked copy-on-write,
//   so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
  801272:	55                   	push   %ebp
  801273:	89 e5                	mov    %esp,%ebp
  801275:	57                   	push   %edi
  801276:	56                   	push   %esi
  801277:	53                   	push   %ebx
  801278:	83 ec 3c             	sub    $0x3c,%esp
    int r   = 0;
    int i;
    envid_t childId = 0;
	// LAB 4: Your code here.
    // Setup parent process pgfault handler.
    set_pgfault_handler(pgfault);
  80127b:	c7 04 24 dc 14 80 00 	movl   $0x8014dc,(%esp)
  801282:	e8 ed 1d 00 00       	call   803074 <set_pgfault_handler>
static __inline envid_t sys_exofork(void) __attribute__((always_inline));
static __inline envid_t
sys_exofork(void)
{
	envid_t ret;
	__asm __volatile("int %2"
  801287:	ba 07 00 00 00       	mov    $0x7,%edx
  80128c:	89 d0                	mov    %edx,%eax
  80128e:	cd 30                	int    $0x30
  801290:	89 45 d8             	mov    %eax,-0x28(%ebp)
    childId=sys_exofork();

    if (childId<0) {
  801293:	85 c0                	test   %eax,%eax
  801295:	79 20                	jns    8012b7 <fork+0x45>
        panic("Parent: sys_exofork. Error: 0x%x\n", childId);
  801297:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80129b:	c7 44 24 08 5c 39 80 	movl   $0x80395c,0x8(%esp)
  8012a2:	00 
  8012a3:	c7 44 24 04 7b 00 00 	movl   $0x7b,0x4(%esp)
  8012aa:	00 
  8012ab:	c7 04 24 ec 38 80 00 	movl   $0x8038ec,(%esp)
  8012b2:	e8 85 ef ff ff       	call   80023c <_panic>
    } else if (childId>0) {
  8012b7:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8012bb:	0f 8e f3 01 00 00    	jle    8014b4 <fork+0x242>
      // Setup child process' pgfault handler.
      if ((r=sys_env_set_pgfault_upcall(childId, _pgfault_upcall))) {
  8012c1:	c7 44 24 04 e4 30 80 	movl   $0x8030e4,0x4(%esp)
  8012c8:	00 
  8012c9:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8012cc:	89 04 24             	mov    %eax,(%esp)
  8012cf:	e8 7c fc ff ff       	call   800f50 <sys_env_set_pgfault_upcall>
  8012d4:	85 c0                	test   %eax,%eax
  8012d6:	74 20                	je     8012f8 <fork+0x86>
          panic("Child: sys_env_set_pgfault_upcall. Error: %d\n", r);
  8012d8:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8012dc:	c7 44 24 08 80 39 80 	movl   $0x803980,0x8(%esp)
  8012e3:	00 
  8012e4:	c7 44 24 04 7f 00 00 	movl   $0x7f,0x4(%esp)
  8012eb:	00 
  8012ec:	c7 04 24 ec 38 80 00 	movl   $0x8038ec,(%esp)
  8012f3:	e8 44 ef ff ff       	call   80023c <_panic>
      }
      
      // Setup child's Image.
      // Allocate page for child's user exception stack.
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
  8012f8:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  8012ff:	00 
  801300:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  801307:	ee 
  801308:	8b 45 d8             	mov    -0x28(%ebp),%eax
  80130b:	89 04 24             	mov    %eax,(%esp)
  80130e:	e8 13 fe ff ff       	call   801126 <sys_page_alloc>
  801313:	85 c0                	test   %eax,%eax
  801315:	79 20                	jns    801337 <fork+0xc5>
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
  801317:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80131b:	c7 44 24 08 b0 39 80 	movl   $0x8039b0,0x8(%esp)
  801322:	00 
  801323:	c7 44 24 04 85 00 00 	movl   $0x85,0x4(%esp)
  80132a:	00 
  80132b:	c7 04 24 ec 38 80 00 	movl   $0x8038ec,(%esp)
  801332:	e8 05 ef ff ff       	call   80023c <_panic>
  801337:	be 00 00 80 00       	mov    $0x800000,%esi
  80133c:	bb 00 00 80 00       	mov    $0x800000,%ebx
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
        if (vpd[VPD(i)]&PTE_P)
  801341:	bf 00 d0 7b ef       	mov    $0xef7bd000,%edi
  801346:	89 f0                	mov    %esi,%eax
  801348:	c1 e8 16             	shr    $0x16,%eax
  80134b:	8b 04 87             	mov    (%edi,%eax,4),%eax
  80134e:	a8 01                	test   $0x1,%al
  801350:	0f 84 13 01 00 00    	je     801469 <fork+0x1f7>
// 
static int
duppage(envid_t envid, unsigned pn)
{
	int r           = 0;
  int perm        = vpt[VPN(pn)]&PTE_USER;
  801356:	89 f0                	mov    %esi,%eax
  801358:	c1 e8 0c             	shr    $0xc,%eax
  80135b:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801362:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  801365:	25 07 0e 00 00       	and    $0xe07,%eax
  80136a:	89 45 e0             	mov    %eax,-0x20(%ebp)
  envid_t env_id  = sys_getenvid();
  80136d:	e8 47 fe ff ff       	call   8011b9 <sys_getenvid>
  801372:	89 45 dc             	mov    %eax,-0x24(%ebp)

	// LAB 4: Your code here.
  if ((perm&PTE_P) && (perm&PTE_W || perm&PTE_COW) && (!(perm&PTE_SHARE))) {
  801375:	f6 45 e4 01          	testb  $0x1,-0x1c(%ebp)
  801379:	0f 84 ea 00 00 00    	je     801469 <fork+0x1f7>
  80137f:	f7 45 e0 02 08 00 00 	testl  $0x802,-0x20(%ebp)
  801386:	0f 84 9d 00 00 00    	je     801429 <fork+0x1b7>
  80138c:	f7 45 e0 00 04 00 00 	testl  $0x400,-0x20(%ebp)
  801393:	0f 85 90 00 00 00    	jne    801429 <fork+0x1b7>
    perm    &= (~PTE_W);
  801399:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80139c:	83 e0 fd             	and    $0xfffffffd,%eax
    perm    |= PTE_COW;
  80139f:	80 cc 08             	or     $0x8,%ah
  8013a2:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  8013a5:	89 75 e0             	mov    %esi,-0x20(%ebp)
  8013a8:	89 44 24 10          	mov    %eax,0x10(%esp)
  8013ac:	89 74 24 0c          	mov    %esi,0xc(%esp)
  8013b0:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8013b3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8013b7:	89 74 24 04          	mov    %esi,0x4(%esp)
  8013bb:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8013be:	89 04 24             	mov    %eax,(%esp)
  8013c1:	e8 02 fd ff ff       	call   8010c8 <sys_page_map>
  8013c6:	85 c0                	test   %eax,%eax
  8013c8:	79 1b                	jns    8013e5 <fork+0x173>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  8013ca:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8013ce:	89 74 24 08          	mov    %esi,0x8(%esp)
  8013d2:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8013d5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8013d9:	c7 04 24 d8 39 80 00 	movl   $0x8039d8,(%esp)
  8013e0:	e8 1c ef ff ff       	call   800301 <cprintf>
    // Map permissions back to parent on COW.
    if ((r=sys_page_map(envid, (void *)pn, env_id, (void *)pn, perm))<0)
  8013e5:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8013e8:	89 44 24 10          	mov    %eax,0x10(%esp)
  8013ec:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8013ef:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8013f3:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8013f6:	89 44 24 08          	mov    %eax,0x8(%esp)
  8013fa:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8013fd:	89 44 24 04          	mov    %eax,0x4(%esp)
  801401:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801404:	89 04 24             	mov    %eax,(%esp)
  801407:	e8 bc fc ff ff       	call   8010c8 <sys_page_map>
  80140c:	85 c0                	test   %eax,%eax
  80140e:	79 59                	jns    801469 <fork+0x1f7>
      cprintf("[0x%x] Mapping to PARENT: sys_page_map. Error: %d\n", env_id, r);
  801410:	89 44 24 08          	mov    %eax,0x8(%esp)
  801414:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801417:	89 44 24 04          	mov    %eax,0x4(%esp)
  80141b:	c7 04 24 18 3a 80 00 	movl   $0x803a18,(%esp)
  801422:	e8 da ee ff ff       	call   800301 <cprintf>
  801427:	eb 40                	jmp    801469 <fork+0x1f7>
  } else if (perm&PTE_P){
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  801429:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80142c:	89 44 24 10          	mov    %eax,0x10(%esp)
  801430:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801434:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801437:	89 44 24 08          	mov    %eax,0x8(%esp)
  80143b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80143f:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801442:	89 04 24             	mov    %eax,(%esp)
  801445:	e8 7e fc ff ff       	call   8010c8 <sys_page_map>
  80144a:	85 c0                	test   %eax,%eax
  80144c:	79 1b                	jns    801469 <fork+0x1f7>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  80144e:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801452:	89 74 24 08          	mov    %esi,0x8(%esp)
  801456:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801459:	89 44 24 04          	mov    %eax,0x4(%esp)
  80145d:	c7 04 24 d8 39 80 00 	movl   $0x8039d8,(%esp)
  801464:	e8 98 ee ff ff       	call   800301 <cprintf>
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
  801469:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  80146f:	89 de                	mov    %ebx,%esi
  801471:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  801477:	0f 85 c9 fe ff ff    	jne    801346 <fork+0xd4>
        if (vpd[VPD(i)]&PTE_P)
          duppage(childId, i);

      // Set child as runnable.
      if ((r = sys_env_set_status(childId, ENV_RUNNABLE)) < 0)
  80147d:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  801484:	00 
  801485:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801488:	89 04 24             	mov    %eax,(%esp)
  80148b:	e8 7c fb ff ff       	call   80100c <sys_env_set_status>
  801490:	85 c0                	test   %eax,%eax
  801492:	79 3d                	jns    8014d1 <fork+0x25f>
        panic("Parent: sys_env_set_status: %e\n", r);
  801494:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801498:	c7 44 24 08 4c 3a 80 	movl   $0x803a4c,0x8(%esp)
  80149f:	00 
  8014a0:	c7 44 24 04 8f 00 00 	movl   $0x8f,0x4(%esp)
  8014a7:	00 
  8014a8:	c7 04 24 ec 38 80 00 	movl   $0x8038ec,(%esp)
  8014af:	e8 88 ed ff ff       	call   80023c <_panic>
    } else if (childId==0) {
  8014b4:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8014b8:	75 17                	jne    8014d1 <fork+0x25f>
      env = &envs [ENVX(sys_getenvid())];
  8014ba:	e8 fa fc ff ff       	call   8011b9 <sys_getenvid>
  8014bf:	25 ff 03 00 00       	and    $0x3ff,%eax
  8014c4:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8014c7:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  8014cc:	a3 7c 70 80 00       	mov    %eax,0x80707c
    }
    return childId;
}
  8014d1:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8014d4:	83 c4 3c             	add    $0x3c,%esp
  8014d7:	5b                   	pop    %ebx
  8014d8:	5e                   	pop    %esi
  8014d9:	5f                   	pop    %edi
  8014da:	5d                   	pop    %ebp
  8014db:	c3                   	ret    

008014dc <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
  8014dc:	55                   	push   %ebp
  8014dd:	89 e5                	mov    %esp,%ebp
  8014df:	57                   	push   %edi
  8014e0:	56                   	push   %esi
  8014e1:	53                   	push   %ebx
  8014e2:	83 ec 3c             	sub    $0x3c,%esp
  void *addr    = (void *) utf->utf_fault_va;
  8014e5:	8b 45 08             	mov    0x8(%ebp),%eax
  8014e8:	8b 38                	mov    (%eax),%edi
  uint32_t err  = utf->utf_err;
  8014ea:	8b 50 04             	mov    0x4(%eax),%edx
  8014ed:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  int r         = 0;
  int perm      = 0;
  void *align   = (void *)((int)addr&(~0xFFF));
  8014f0:	89 fe                	mov    %edi,%esi
  8014f2:	81 e6 00 f0 ff ff    	and    $0xfffff000,%esi
  envid_t envid = sys_getenvid();
  8014f8:	e8 bc fc ff ff       	call   8011b9 <sys_getenvid>
  8014fd:	89 c3                	mov    %eax,%ebx
	// copy-on-write page.  If not, panic.
	// Hint:
	//   Use the read-only page table mappings at vpt
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
  8014ff:	89 f2                	mov    %esi,%edx
  801501:	89 f0                	mov    %esi,%eax
  801503:	c1 e8 16             	shr    $0x16,%eax
  801506:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  80150d:	a8 01                	test   $0x1,%al
  80150f:	74 3e                	je     80154f <pgfault+0x73>
  801511:	c1 ea 0c             	shr    $0xc,%edx
  801514:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  80151b:	a8 01                	test   $0x1,%al
  80151d:	74 30                	je     80154f <pgfault+0x73>
    perm  = vpt[VPN(addr)]&PTE_USER;
  80151f:	c1 ef 0c             	shr    $0xc,%edi
  801522:	8b 3c bd 00 00 40 ef 	mov    -0x10c00000(,%edi,4),%edi
	// page to the old page's address.
	// Hint:
	//   You should make three system calls.
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  801529:	81 e7 07 06 00 00    	and    $0x607,%edi
  perm    |= PTE_W;
  80152f:	83 cf 02             	or     $0x2,%edi
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
  801532:	89 7c 24 08          	mov    %edi,0x8(%esp)
  801536:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80153d:	00 
  80153e:	89 1c 24             	mov    %ebx,(%esp)
  801541:	e8 e0 fb ff ff       	call   801126 <sys_page_alloc>
  801546:	85 c0                	test   %eax,%eax
  801548:	74 46                	je     801590 <pgfault+0xb4>
  80154a:	e9 cd 00 00 00       	jmp    80161c <pgfault+0x140>
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
    perm  = vpt[VPN(addr)]&PTE_USER;
  else {
    cprintf("Tryig to acess address: %x eip: %x Err: %x\n", align, utf->utf_eip, err);
  80154f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801552:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801556:	8b 55 08             	mov    0x8(%ebp),%edx
  801559:	8b 42 28             	mov    0x28(%edx),%eax
  80155c:	89 44 24 08          	mov    %eax,0x8(%esp)
  801560:	89 74 24 04          	mov    %esi,0x4(%esp)
  801564:	c7 04 24 6c 3a 80 00 	movl   $0x803a6c,(%esp)
  80156b:	e8 91 ed ff ff       	call   800301 <cprintf>
    panic("Go to hell :[%x]\n", envid);
  801570:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  801574:	c7 44 24 08 f7 38 80 	movl   $0x8038f7,0x8(%esp)
  80157b:	00 
  80157c:	c7 44 24 04 24 00 00 	movl   $0x24,0x4(%esp)
  801583:	00 
  801584:	c7 04 24 ec 38 80 00 	movl   $0x8038ec,(%esp)
  80158b:	e8 ac ec ff ff       	call   80023c <_panic>
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  perm    |= PTE_W;
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
    memmove((void *)PFTEMP, align, PGSIZE);
  801590:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  801597:	00 
  801598:	89 74 24 04          	mov    %esi,0x4(%esp)
  80159c:	c7 04 24 00 f0 7f 00 	movl   $0x7ff000,(%esp)
  8015a3:	e8 dd f5 ff ff       	call   800b85 <memmove>
    if((r=sys_page_map(envid, (void *)PFTEMP, envid, align, perm)))
  8015a8:	89 7c 24 10          	mov    %edi,0x10(%esp)
  8015ac:	89 74 24 0c          	mov    %esi,0xc(%esp)
  8015b0:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8015b4:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  8015bb:	00 
  8015bc:	89 1c 24             	mov    %ebx,(%esp)
  8015bf:	e8 04 fb ff ff       	call   8010c8 <sys_page_map>
  8015c4:	85 c0                	test   %eax,%eax
  8015c6:	74 20                	je     8015e8 <pgfault+0x10c>
      panic("sys_page_map. Error: 0x%x\n", r);
  8015c8:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8015cc:	c7 44 24 08 09 39 80 	movl   $0x803909,0x8(%esp)
  8015d3:	00 
  8015d4:	c7 44 24 04 34 00 00 	movl   $0x34,0x4(%esp)
  8015db:	00 
  8015dc:	c7 04 24 ec 38 80 00 	movl   $0x8038ec,(%esp)
  8015e3:	e8 54 ec ff ff       	call   80023c <_panic>

    if ((r=sys_page_unmap(envid, (void *)PFTEMP)))
  8015e8:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  8015ef:	00 
  8015f0:	89 1c 24             	mov    %ebx,(%esp)
  8015f3:	e8 72 fa ff ff       	call   80106a <sys_page_unmap>
  8015f8:	85 c0                	test   %eax,%eax
  8015fa:	74 40                	je     80163c <pgfault+0x160>
      panic("sys_page_unmap. Error: 0x%x\n", r);
  8015fc:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801600:	c7 44 24 08 24 39 80 	movl   $0x803924,0x8(%esp)
  801607:	00 
  801608:	c7 44 24 04 37 00 00 	movl   $0x37,0x4(%esp)
  80160f:	00 
  801610:	c7 04 24 ec 38 80 00 	movl   $0x8038ec,(%esp)
  801617:	e8 20 ec ff ff       	call   80023c <_panic>
  } else
    panic("sys_page_alloc. Error: %d\n", r);
  80161c:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801620:	c7 44 24 08 41 39 80 	movl   $0x803941,0x8(%esp)
  801627:	00 
  801628:	c7 44 24 04 39 00 00 	movl   $0x39,0x4(%esp)
  80162f:	00 
  801630:	c7 04 24 ec 38 80 00 	movl   $0x8038ec,(%esp)
  801637:	e8 00 ec ff ff       	call   80023c <_panic>
}
  80163c:	83 c4 3c             	add    $0x3c,%esp
  80163f:	5b                   	pop    %ebx
  801640:	5e                   	pop    %esi
  801641:	5f                   	pop    %edi
  801642:	5d                   	pop    %ebp
  801643:	c3                   	ret    
	...

00801650 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  801650:	55                   	push   %ebp
  801651:	89 e5                	mov    %esp,%ebp
  801653:	8b 45 08             	mov    0x8(%ebp),%eax
  801656:	05 00 00 00 30       	add    $0x30000000,%eax
  80165b:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  80165e:	5d                   	pop    %ebp
  80165f:	c3                   	ret    

00801660 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801660:	55                   	push   %ebp
  801661:	89 e5                	mov    %esp,%ebp
  801663:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  801666:	8b 45 08             	mov    0x8(%ebp),%eax
  801669:	89 04 24             	mov    %eax,(%esp)
  80166c:	e8 df ff ff ff       	call   801650 <fd2num>
  801671:	05 20 00 0d 00       	add    $0xd0020,%eax
  801676:	c1 e0 0c             	shl    $0xc,%eax
}
  801679:	c9                   	leave  
  80167a:	c3                   	ret    

0080167b <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  80167b:	55                   	push   %ebp
  80167c:	89 e5                	mov    %esp,%ebp
  80167e:	57                   	push   %edi
  80167f:	56                   	push   %esi
  801680:	53                   	push   %ebx
  801681:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  801684:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  801689:	a8 01                	test   $0x1,%al
  80168b:	74 36                	je     8016c3 <fd_alloc+0x48>
  80168d:	a1 00 00 74 ef       	mov    0xef740000,%eax
  801692:	a8 01                	test   $0x1,%al
  801694:	74 2d                	je     8016c3 <fd_alloc+0x48>
  801696:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  80169b:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  8016a0:	be 00 00 40 ef       	mov    $0xef400000,%esi
  8016a5:	89 c3                	mov    %eax,%ebx
  8016a7:	89 c2                	mov    %eax,%edx
  8016a9:	c1 ea 16             	shr    $0x16,%edx
  8016ac:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  8016af:	f6 c2 01             	test   $0x1,%dl
  8016b2:	74 14                	je     8016c8 <fd_alloc+0x4d>
  8016b4:	89 c2                	mov    %eax,%edx
  8016b6:	c1 ea 0c             	shr    $0xc,%edx
  8016b9:	8b 14 96             	mov    (%esi,%edx,4),%edx
  8016bc:	f6 c2 01             	test   $0x1,%dl
  8016bf:	75 10                	jne    8016d1 <fd_alloc+0x56>
  8016c1:	eb 05                	jmp    8016c8 <fd_alloc+0x4d>
  8016c3:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  8016c8:	89 1f                	mov    %ebx,(%edi)
  8016ca:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  8016cf:	eb 17                	jmp    8016e8 <fd_alloc+0x6d>
  8016d1:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  8016d6:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  8016db:	75 c8                	jne    8016a5 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  8016dd:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  8016e3:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  8016e8:	5b                   	pop    %ebx
  8016e9:	5e                   	pop    %esi
  8016ea:	5f                   	pop    %edi
  8016eb:	5d                   	pop    %ebp
  8016ec:	c3                   	ret    

008016ed <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  8016ed:	55                   	push   %ebp
  8016ee:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  8016f0:	8b 45 08             	mov    0x8(%ebp),%eax
  8016f3:	83 f8 1f             	cmp    $0x1f,%eax
  8016f6:	77 36                	ja     80172e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  8016f8:	05 00 00 0d 00       	add    $0xd0000,%eax
  8016fd:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  801700:	89 c2                	mov    %eax,%edx
  801702:	c1 ea 16             	shr    $0x16,%edx
  801705:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  80170c:	f6 c2 01             	test   $0x1,%dl
  80170f:	74 1d                	je     80172e <fd_lookup+0x41>
  801711:	89 c2                	mov    %eax,%edx
  801713:	c1 ea 0c             	shr    $0xc,%edx
  801716:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  80171d:	f6 c2 01             	test   $0x1,%dl
  801720:	74 0c                	je     80172e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  801722:	8b 55 0c             	mov    0xc(%ebp),%edx
  801725:	89 02                	mov    %eax,(%edx)
  801727:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  80172c:	eb 05                	jmp    801733 <fd_lookup+0x46>
  80172e:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801733:	5d                   	pop    %ebp
  801734:	c3                   	ret    

00801735 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  801735:	55                   	push   %ebp
  801736:	89 e5                	mov    %esp,%ebp
  801738:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80173b:	8d 45 fc             	lea    -0x4(%ebp),%eax
  80173e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801742:	8b 45 08             	mov    0x8(%ebp),%eax
  801745:	89 04 24             	mov    %eax,(%esp)
  801748:	e8 a0 ff ff ff       	call   8016ed <fd_lookup>
  80174d:	85 c0                	test   %eax,%eax
  80174f:	78 0e                	js     80175f <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  801751:	8b 45 fc             	mov    -0x4(%ebp),%eax
  801754:	8b 55 0c             	mov    0xc(%ebp),%edx
  801757:	89 50 04             	mov    %edx,0x4(%eax)
  80175a:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  80175f:	c9                   	leave  
  801760:	c3                   	ret    

00801761 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  801761:	55                   	push   %ebp
  801762:	89 e5                	mov    %esp,%ebp
  801764:	56                   	push   %esi
  801765:	53                   	push   %ebx
  801766:	83 ec 10             	sub    $0x10,%esp
  801769:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80176c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  80176f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  801774:	b8 0c 70 80 00       	mov    $0x80700c,%eax
  801779:	39 0d 0c 70 80 00    	cmp    %ecx,0x80700c
  80177f:	75 11                	jne    801792 <dev_lookup+0x31>
  801781:	eb 04                	jmp    801787 <dev_lookup+0x26>
  801783:	39 08                	cmp    %ecx,(%eax)
  801785:	75 10                	jne    801797 <dev_lookup+0x36>
			*dev = devtab[i];
  801787:	89 03                	mov    %eax,(%ebx)
  801789:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80178e:	66 90                	xchg   %ax,%ax
  801790:	eb 36                	jmp    8017c8 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  801792:	be 14 3b 80 00       	mov    $0x803b14,%esi
  801797:	83 c2 01             	add    $0x1,%edx
  80179a:	8b 04 96             	mov    (%esi,%edx,4),%eax
  80179d:	85 c0                	test   %eax,%eax
  80179f:	75 e2                	jne    801783 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  8017a1:	a1 7c 70 80 00       	mov    0x80707c,%eax
  8017a6:	8b 40 4c             	mov    0x4c(%eax),%eax
  8017a9:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8017ad:	89 44 24 04          	mov    %eax,0x4(%esp)
  8017b1:	c7 04 24 98 3a 80 00 	movl   $0x803a98,(%esp)
  8017b8:	e8 44 eb ff ff       	call   800301 <cprintf>
	*dev = 0;
  8017bd:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  8017c3:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  8017c8:	83 c4 10             	add    $0x10,%esp
  8017cb:	5b                   	pop    %ebx
  8017cc:	5e                   	pop    %esi
  8017cd:	5d                   	pop    %ebp
  8017ce:	c3                   	ret    

008017cf <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  8017cf:	55                   	push   %ebp
  8017d0:	89 e5                	mov    %esp,%ebp
  8017d2:	53                   	push   %ebx
  8017d3:	83 ec 24             	sub    $0x24,%esp
  8017d6:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8017d9:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8017dc:	89 44 24 04          	mov    %eax,0x4(%esp)
  8017e0:	8b 45 08             	mov    0x8(%ebp),%eax
  8017e3:	89 04 24             	mov    %eax,(%esp)
  8017e6:	e8 02 ff ff ff       	call   8016ed <fd_lookup>
  8017eb:	85 c0                	test   %eax,%eax
  8017ed:	78 53                	js     801842 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8017ef:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8017f2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8017f6:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8017f9:	8b 00                	mov    (%eax),%eax
  8017fb:	89 04 24             	mov    %eax,(%esp)
  8017fe:	e8 5e ff ff ff       	call   801761 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801803:	85 c0                	test   %eax,%eax
  801805:	78 3b                	js     801842 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  801807:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  80180c:	8b 55 f4             	mov    -0xc(%ebp),%edx
  80180f:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  801813:	74 2d                	je     801842 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  801815:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  801818:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  80181f:	00 00 00 
	stat->st_isdir = 0;
  801822:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  801829:	00 00 00 
	stat->st_dev = dev;
  80182c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80182f:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  801835:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801839:	8b 55 f0             	mov    -0x10(%ebp),%edx
  80183c:	89 14 24             	mov    %edx,(%esp)
  80183f:	ff 50 14             	call   *0x14(%eax)
}
  801842:	83 c4 24             	add    $0x24,%esp
  801845:	5b                   	pop    %ebx
  801846:	5d                   	pop    %ebp
  801847:	c3                   	ret    

00801848 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  801848:	55                   	push   %ebp
  801849:	89 e5                	mov    %esp,%ebp
  80184b:	53                   	push   %ebx
  80184c:	83 ec 24             	sub    $0x24,%esp
  80184f:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801852:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801855:	89 44 24 04          	mov    %eax,0x4(%esp)
  801859:	89 1c 24             	mov    %ebx,(%esp)
  80185c:	e8 8c fe ff ff       	call   8016ed <fd_lookup>
  801861:	85 c0                	test   %eax,%eax
  801863:	78 5f                	js     8018c4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801865:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801868:	89 44 24 04          	mov    %eax,0x4(%esp)
  80186c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80186f:	8b 00                	mov    (%eax),%eax
  801871:	89 04 24             	mov    %eax,(%esp)
  801874:	e8 e8 fe ff ff       	call   801761 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801879:	85 c0                	test   %eax,%eax
  80187b:	78 47                	js     8018c4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80187d:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801880:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801884:	75 23                	jne    8018a9 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  801886:	a1 7c 70 80 00       	mov    0x80707c,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  80188b:	8b 40 4c             	mov    0x4c(%eax),%eax
  80188e:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801892:	89 44 24 04          	mov    %eax,0x4(%esp)
  801896:	c7 04 24 b8 3a 80 00 	movl   $0x803ab8,(%esp)
  80189d:	e8 5f ea ff ff       	call   800301 <cprintf>
  8018a2:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  8018a7:	eb 1b                	jmp    8018c4 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  8018a9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8018ac:	8b 48 18             	mov    0x18(%eax),%ecx
  8018af:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8018b4:	85 c9                	test   %ecx,%ecx
  8018b6:	74 0c                	je     8018c4 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  8018b8:	8b 45 0c             	mov    0xc(%ebp),%eax
  8018bb:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018bf:	89 14 24             	mov    %edx,(%esp)
  8018c2:	ff d1                	call   *%ecx
}
  8018c4:	83 c4 24             	add    $0x24,%esp
  8018c7:	5b                   	pop    %ebx
  8018c8:	5d                   	pop    %ebp
  8018c9:	c3                   	ret    

008018ca <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  8018ca:	55                   	push   %ebp
  8018cb:	89 e5                	mov    %esp,%ebp
  8018cd:	53                   	push   %ebx
  8018ce:	83 ec 24             	sub    $0x24,%esp
  8018d1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8018d4:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8018d7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018db:	89 1c 24             	mov    %ebx,(%esp)
  8018de:	e8 0a fe ff ff       	call   8016ed <fd_lookup>
  8018e3:	85 c0                	test   %eax,%eax
  8018e5:	78 66                	js     80194d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8018e7:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8018ea:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018ee:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8018f1:	8b 00                	mov    (%eax),%eax
  8018f3:	89 04 24             	mov    %eax,(%esp)
  8018f6:	e8 66 fe ff ff       	call   801761 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8018fb:	85 c0                	test   %eax,%eax
  8018fd:	78 4e                	js     80194d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  8018ff:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801902:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801906:	75 23                	jne    80192b <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  801908:	a1 7c 70 80 00       	mov    0x80707c,%eax
  80190d:	8b 40 4c             	mov    0x4c(%eax),%eax
  801910:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801914:	89 44 24 04          	mov    %eax,0x4(%esp)
  801918:	c7 04 24 d9 3a 80 00 	movl   $0x803ad9,(%esp)
  80191f:	e8 dd e9 ff ff       	call   800301 <cprintf>
  801924:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801929:	eb 22                	jmp    80194d <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  80192b:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80192e:	8b 48 0c             	mov    0xc(%eax),%ecx
  801931:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801936:	85 c9                	test   %ecx,%ecx
  801938:	74 13                	je     80194d <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  80193a:	8b 45 10             	mov    0x10(%ebp),%eax
  80193d:	89 44 24 08          	mov    %eax,0x8(%esp)
  801941:	8b 45 0c             	mov    0xc(%ebp),%eax
  801944:	89 44 24 04          	mov    %eax,0x4(%esp)
  801948:	89 14 24             	mov    %edx,(%esp)
  80194b:	ff d1                	call   *%ecx
}
  80194d:	83 c4 24             	add    $0x24,%esp
  801950:	5b                   	pop    %ebx
  801951:	5d                   	pop    %ebp
  801952:	c3                   	ret    

00801953 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  801953:	55                   	push   %ebp
  801954:	89 e5                	mov    %esp,%ebp
  801956:	57                   	push   %edi
  801957:	56                   	push   %esi
  801958:	53                   	push   %ebx
  801959:	83 ec 2c             	sub    $0x2c,%esp
  80195c:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80195f:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801962:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801965:	89 44 24 04          	mov    %eax,0x4(%esp)
  801969:	89 1c 24             	mov    %ebx,(%esp)
  80196c:	e8 7c fd ff ff       	call   8016ed <fd_lookup>
  801971:	85 c0                	test   %eax,%eax
  801973:	0f 88 b0 00 00 00    	js     801a29 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801979:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80197c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801980:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801983:	8b 00                	mov    (%eax),%eax
  801985:	89 04 24             	mov    %eax,(%esp)
  801988:	e8 d4 fd ff ff       	call   801761 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  80198d:	85 c0                	test   %eax,%eax
  80198f:	0f 88 94 00 00 00    	js     801a29 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  801995:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801998:	8b 40 08             	mov    0x8(%eax),%eax
  80199b:	83 e0 03             	and    $0x3,%eax
  80199e:	83 f8 01             	cmp    $0x1,%eax
  8019a1:	75 23                	jne    8019c6 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  8019a3:	a1 7c 70 80 00       	mov    0x80707c,%eax
  8019a8:	8b 40 4c             	mov    0x4c(%eax),%eax
  8019ab:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8019af:	89 44 24 04          	mov    %eax,0x4(%esp)
  8019b3:	c7 04 24 f6 3a 80 00 	movl   $0x803af6,(%esp)
  8019ba:	e8 42 e9 ff ff       	call   800301 <cprintf>
  8019bf:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  8019c4:	eb 63                	jmp    801a29 <read+0xd6>
	}
	if (!dev->dev_read)
  8019c6:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8019cb:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8019ce:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  8019d2:	74 55                	je     801a29 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  8019d4:	ba 00 00 00 00       	mov    $0x0,%edx
  8019d9:	bb 00 00 00 00       	mov    $0x0,%ebx
  8019de:	b8 00 00 00 00       	mov    $0x0,%eax
  8019e3:	85 f6                	test   %esi,%esi
  8019e5:	74 42                	je     801a29 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  8019e7:	bf 00 10 00 00       	mov    $0x1000,%edi
  8019ec:	89 f0                	mov    %esi,%eax
  8019ee:	29 d0                	sub    %edx,%eax
  8019f0:	89 c1                	mov    %eax,%ecx
  8019f2:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  8019f8:	3d 00 10 00 00       	cmp    $0x1000,%eax
  8019fd:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  801a00:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  801a04:	03 55 0c             	add    0xc(%ebp),%edx
  801a07:	89 54 24 04          	mov    %edx,0x4(%esp)
  801a0b:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801a0e:	89 04 24             	mov    %eax,(%esp)
  801a11:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801a14:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  801a17:	85 c0                	test   %eax,%eax
  801a19:	78 0e                	js     801a29 <read+0xd6>
			return m;
		if (m == 0)
  801a1b:	85 c0                	test   %eax,%eax
  801a1d:	74 08                	je     801a27 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801a1f:	01 c3                	add    %eax,%ebx
  801a21:	89 da                	mov    %ebx,%edx
  801a23:	39 f3                	cmp    %esi,%ebx
  801a25:	72 c5                	jb     8019ec <read+0x99>
  801a27:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801a29:	83 c4 2c             	add    $0x2c,%esp
  801a2c:	5b                   	pop    %ebx
  801a2d:	5e                   	pop    %esi
  801a2e:	5f                   	pop    %edi
  801a2f:	5d                   	pop    %ebp
  801a30:	c3                   	ret    

00801a31 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  801a31:	55                   	push   %ebp
  801a32:	89 e5                	mov    %esp,%ebp
  801a34:	57                   	push   %edi
  801a35:	56                   	push   %esi
  801a36:	53                   	push   %ebx
  801a37:	83 ec 1c             	sub    $0x1c,%esp
  801a3a:	8b 7d 08             	mov    0x8(%ebp),%edi
  801a3d:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801a40:	ba 00 00 00 00       	mov    $0x0,%edx
  801a45:	bb 00 00 00 00       	mov    $0x0,%ebx
  801a4a:	b8 00 00 00 00       	mov    $0x0,%eax
  801a4f:	85 f6                	test   %esi,%esi
  801a51:	74 29                	je     801a7c <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801a53:	89 f0                	mov    %esi,%eax
  801a55:	29 d0                	sub    %edx,%eax
  801a57:	89 44 24 08          	mov    %eax,0x8(%esp)
  801a5b:	03 55 0c             	add    0xc(%ebp),%edx
  801a5e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801a62:	89 3c 24             	mov    %edi,(%esp)
  801a65:	e8 e9 fe ff ff       	call   801953 <read>
		if (m < 0)
  801a6a:	85 c0                	test   %eax,%eax
  801a6c:	78 0e                	js     801a7c <readn+0x4b>
			return m;
		if (m == 0)
  801a6e:	85 c0                	test   %eax,%eax
  801a70:	74 08                	je     801a7a <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801a72:	01 c3                	add    %eax,%ebx
  801a74:	89 da                	mov    %ebx,%edx
  801a76:	39 f3                	cmp    %esi,%ebx
  801a78:	72 d9                	jb     801a53 <readn+0x22>
  801a7a:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801a7c:	83 c4 1c             	add    $0x1c,%esp
  801a7f:	5b                   	pop    %ebx
  801a80:	5e                   	pop    %esi
  801a81:	5f                   	pop    %edi
  801a82:	5d                   	pop    %ebp
  801a83:	c3                   	ret    

00801a84 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  801a84:	55                   	push   %ebp
  801a85:	89 e5                	mov    %esp,%ebp
  801a87:	83 ec 28             	sub    $0x28,%esp
  801a8a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801a8d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801a90:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801a93:	89 34 24             	mov    %esi,(%esp)
  801a96:	e8 b5 fb ff ff       	call   801650 <fd2num>
  801a9b:	8d 55 f4             	lea    -0xc(%ebp),%edx
  801a9e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801aa2:	89 04 24             	mov    %eax,(%esp)
  801aa5:	e8 43 fc ff ff       	call   8016ed <fd_lookup>
  801aaa:	89 c3                	mov    %eax,%ebx
  801aac:	85 c0                	test   %eax,%eax
  801aae:	78 05                	js     801ab5 <fd_close+0x31>
  801ab0:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  801ab3:	74 0e                	je     801ac3 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  801ab5:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  801ab9:	b8 00 00 00 00       	mov    $0x0,%eax
  801abe:	0f 44 d8             	cmove  %eax,%ebx
  801ac1:	eb 3d                	jmp    801b00 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  801ac3:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801ac6:	89 44 24 04          	mov    %eax,0x4(%esp)
  801aca:	8b 06                	mov    (%esi),%eax
  801acc:	89 04 24             	mov    %eax,(%esp)
  801acf:	e8 8d fc ff ff       	call   801761 <dev_lookup>
  801ad4:	89 c3                	mov    %eax,%ebx
  801ad6:	85 c0                	test   %eax,%eax
  801ad8:	78 16                	js     801af0 <fd_close+0x6c>
		if (dev->dev_close)
  801ada:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801add:	8b 40 10             	mov    0x10(%eax),%eax
  801ae0:	bb 00 00 00 00       	mov    $0x0,%ebx
  801ae5:	85 c0                	test   %eax,%eax
  801ae7:	74 07                	je     801af0 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  801ae9:	89 34 24             	mov    %esi,(%esp)
  801aec:	ff d0                	call   *%eax
  801aee:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  801af0:	89 74 24 04          	mov    %esi,0x4(%esp)
  801af4:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801afb:	e8 6a f5 ff ff       	call   80106a <sys_page_unmap>
	return r;
}
  801b00:	89 d8                	mov    %ebx,%eax
  801b02:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801b05:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801b08:	89 ec                	mov    %ebp,%esp
  801b0a:	5d                   	pop    %ebp
  801b0b:	c3                   	ret    

00801b0c <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  801b0c:	55                   	push   %ebp
  801b0d:	89 e5                	mov    %esp,%ebp
  801b0f:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801b12:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801b15:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b19:	8b 45 08             	mov    0x8(%ebp),%eax
  801b1c:	89 04 24             	mov    %eax,(%esp)
  801b1f:	e8 c9 fb ff ff       	call   8016ed <fd_lookup>
  801b24:	85 c0                	test   %eax,%eax
  801b26:	78 13                	js     801b3b <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  801b28:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  801b2f:	00 
  801b30:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801b33:	89 04 24             	mov    %eax,(%esp)
  801b36:	e8 49 ff ff ff       	call   801a84 <fd_close>
}
  801b3b:	c9                   	leave  
  801b3c:	c3                   	ret    

00801b3d <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  801b3d:	55                   	push   %ebp
  801b3e:	89 e5                	mov    %esp,%ebp
  801b40:	83 ec 18             	sub    $0x18,%esp
  801b43:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801b46:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  801b49:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801b50:	00 
  801b51:	8b 45 08             	mov    0x8(%ebp),%eax
  801b54:	89 04 24             	mov    %eax,(%esp)
  801b57:	e8 80 03 00 00       	call   801edc <open>
  801b5c:	89 c3                	mov    %eax,%ebx
  801b5e:	85 c0                	test   %eax,%eax
  801b60:	78 1b                	js     801b7d <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  801b62:	8b 45 0c             	mov    0xc(%ebp),%eax
  801b65:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b69:	89 1c 24             	mov    %ebx,(%esp)
  801b6c:	e8 5e fc ff ff       	call   8017cf <fstat>
  801b71:	89 c6                	mov    %eax,%esi
	close(fd);
  801b73:	89 1c 24             	mov    %ebx,(%esp)
  801b76:	e8 91 ff ff ff       	call   801b0c <close>
  801b7b:	89 f3                	mov    %esi,%ebx
	return r;
}
  801b7d:	89 d8                	mov    %ebx,%eax
  801b7f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801b82:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801b85:	89 ec                	mov    %ebp,%esp
  801b87:	5d                   	pop    %ebp
  801b88:	c3                   	ret    

00801b89 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  801b89:	55                   	push   %ebp
  801b8a:	89 e5                	mov    %esp,%ebp
  801b8c:	53                   	push   %ebx
  801b8d:	83 ec 14             	sub    $0x14,%esp
  801b90:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  801b95:	89 1c 24             	mov    %ebx,(%esp)
  801b98:	e8 6f ff ff ff       	call   801b0c <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  801b9d:	83 c3 01             	add    $0x1,%ebx
  801ba0:	83 fb 20             	cmp    $0x20,%ebx
  801ba3:	75 f0                	jne    801b95 <close_all+0xc>
		close(i);
}
  801ba5:	83 c4 14             	add    $0x14,%esp
  801ba8:	5b                   	pop    %ebx
  801ba9:	5d                   	pop    %ebp
  801baa:	c3                   	ret    

00801bab <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  801bab:	55                   	push   %ebp
  801bac:	89 e5                	mov    %esp,%ebp
  801bae:	83 ec 58             	sub    $0x58,%esp
  801bb1:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801bb4:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801bb7:	89 7d fc             	mov    %edi,-0x4(%ebp)
  801bba:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  801bbd:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801bc0:	89 44 24 04          	mov    %eax,0x4(%esp)
  801bc4:	8b 45 08             	mov    0x8(%ebp),%eax
  801bc7:	89 04 24             	mov    %eax,(%esp)
  801bca:	e8 1e fb ff ff       	call   8016ed <fd_lookup>
  801bcf:	89 c3                	mov    %eax,%ebx
  801bd1:	85 c0                	test   %eax,%eax
  801bd3:	0f 88 e0 00 00 00    	js     801cb9 <dup+0x10e>
		return r;
	close(newfdnum);
  801bd9:	89 3c 24             	mov    %edi,(%esp)
  801bdc:	e8 2b ff ff ff       	call   801b0c <close>

	newfd = INDEX2FD(newfdnum);
  801be1:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  801be7:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  801bea:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801bed:	89 04 24             	mov    %eax,(%esp)
  801bf0:	e8 6b fa ff ff       	call   801660 <fd2data>
  801bf5:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  801bf7:	89 34 24             	mov    %esi,(%esp)
  801bfa:	e8 61 fa ff ff       	call   801660 <fd2data>
  801bff:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  801c02:	89 da                	mov    %ebx,%edx
  801c04:	89 d8                	mov    %ebx,%eax
  801c06:	c1 e8 16             	shr    $0x16,%eax
  801c09:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801c10:	a8 01                	test   $0x1,%al
  801c12:	74 43                	je     801c57 <dup+0xac>
  801c14:	c1 ea 0c             	shr    $0xc,%edx
  801c17:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801c1e:	a8 01                	test   $0x1,%al
  801c20:	74 35                	je     801c57 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  801c22:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801c29:	25 07 0e 00 00       	and    $0xe07,%eax
  801c2e:	89 44 24 10          	mov    %eax,0x10(%esp)
  801c32:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801c35:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801c39:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801c40:	00 
  801c41:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801c45:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801c4c:	e8 77 f4 ff ff       	call   8010c8 <sys_page_map>
  801c51:	89 c3                	mov    %eax,%ebx
  801c53:	85 c0                	test   %eax,%eax
  801c55:	78 3f                	js     801c96 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  801c57:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801c5a:	89 c2                	mov    %eax,%edx
  801c5c:	c1 ea 0c             	shr    $0xc,%edx
  801c5f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801c66:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  801c6c:	89 54 24 10          	mov    %edx,0x10(%esp)
  801c70:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801c74:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801c7b:	00 
  801c7c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c80:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801c87:	e8 3c f4 ff ff       	call   8010c8 <sys_page_map>
  801c8c:	89 c3                	mov    %eax,%ebx
  801c8e:	85 c0                	test   %eax,%eax
  801c90:	78 04                	js     801c96 <dup+0xeb>
  801c92:	89 fb                	mov    %edi,%ebx
  801c94:	eb 23                	jmp    801cb9 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  801c96:	89 74 24 04          	mov    %esi,0x4(%esp)
  801c9a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801ca1:	e8 c4 f3 ff ff       	call   80106a <sys_page_unmap>
	sys_page_unmap(0, nva);
  801ca6:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801ca9:	89 44 24 04          	mov    %eax,0x4(%esp)
  801cad:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801cb4:	e8 b1 f3 ff ff       	call   80106a <sys_page_unmap>
	return r;
}
  801cb9:	89 d8                	mov    %ebx,%eax
  801cbb:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801cbe:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801cc1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801cc4:	89 ec                	mov    %ebp,%esp
  801cc6:	5d                   	pop    %ebp
  801cc7:	c3                   	ret    

00801cc8 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  801cc8:	55                   	push   %ebp
  801cc9:	89 e5                	mov    %esp,%ebp
  801ccb:	53                   	push   %ebx
  801ccc:	83 ec 14             	sub    $0x14,%esp
  801ccf:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  801cd1:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  801cd7:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  801cde:	00 
  801cdf:	c7 44 24 08 00 40 80 	movl   $0x804000,0x8(%esp)
  801ce6:	00 
  801ce7:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ceb:	89 14 24             	mov    %edx,(%esp)
  801cee:	e8 1d 14 00 00       	call   803110 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  801cf3:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801cfa:	00 
  801cfb:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801cff:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801d06:	e8 77 14 00 00       	call   803182 <ipc_recv>
}
  801d0b:	83 c4 14             	add    $0x14,%esp
  801d0e:	5b                   	pop    %ebx
  801d0f:	5d                   	pop    %ebp
  801d10:	c3                   	ret    

00801d11 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  801d11:	55                   	push   %ebp
  801d12:	89 e5                	mov    %esp,%ebp
  801d14:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  801d17:	8b 45 08             	mov    0x8(%ebp),%eax
  801d1a:	8b 40 0c             	mov    0xc(%eax),%eax
  801d1d:	a3 00 40 80 00       	mov    %eax,0x804000
	fsipcbuf.set_size.req_size = newsize;
  801d22:	8b 45 0c             	mov    0xc(%ebp),%eax
  801d25:	a3 04 40 80 00       	mov    %eax,0x804004
	return fsipc(FSREQ_SET_SIZE, NULL);
  801d2a:	ba 00 00 00 00       	mov    $0x0,%edx
  801d2f:	b8 02 00 00 00       	mov    $0x2,%eax
  801d34:	e8 8f ff ff ff       	call   801cc8 <fsipc>
}
  801d39:	c9                   	leave  
  801d3a:	c3                   	ret    

00801d3b <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  801d3b:	55                   	push   %ebp
  801d3c:	89 e5                	mov    %esp,%ebp
  801d3e:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  801d41:	8b 45 08             	mov    0x8(%ebp),%eax
  801d44:	8b 40 0c             	mov    0xc(%eax),%eax
  801d47:	a3 00 40 80 00       	mov    %eax,0x804000
	return fsipc(FSREQ_FLUSH, NULL);
  801d4c:	ba 00 00 00 00       	mov    $0x0,%edx
  801d51:	b8 06 00 00 00       	mov    $0x6,%eax
  801d56:	e8 6d ff ff ff       	call   801cc8 <fsipc>
}
  801d5b:	c9                   	leave  
  801d5c:	c3                   	ret    

00801d5d <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  801d5d:	55                   	push   %ebp
  801d5e:	89 e5                	mov    %esp,%ebp
  801d60:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801d63:	ba 00 00 00 00       	mov    $0x0,%edx
  801d68:	b8 08 00 00 00       	mov    $0x8,%eax
  801d6d:	e8 56 ff ff ff       	call   801cc8 <fsipc>
}
  801d72:	c9                   	leave  
  801d73:	c3                   	ret    

00801d74 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  801d74:	55                   	push   %ebp
  801d75:	89 e5                	mov    %esp,%ebp
  801d77:	53                   	push   %ebx
  801d78:	83 ec 14             	sub    $0x14,%esp
  801d7b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  801d7e:	8b 45 08             	mov    0x8(%ebp),%eax
  801d81:	8b 40 0c             	mov    0xc(%eax),%eax
  801d84:	a3 00 40 80 00       	mov    %eax,0x804000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801d89:	ba 00 00 00 00       	mov    $0x0,%edx
  801d8e:	b8 05 00 00 00       	mov    $0x5,%eax
  801d93:	e8 30 ff ff ff       	call   801cc8 <fsipc>
  801d98:	85 c0                	test   %eax,%eax
  801d9a:	78 2b                	js     801dc7 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  801d9c:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801da3:	00 
  801da4:	89 1c 24             	mov    %ebx,(%esp)
  801da7:	e8 1e ec ff ff       	call   8009ca <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  801dac:	a1 80 40 80 00       	mov    0x804080,%eax
  801db1:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  801db7:	a1 84 40 80 00       	mov    0x804084,%eax
  801dbc:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  801dc2:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  801dc7:	83 c4 14             	add    $0x14,%esp
  801dca:	5b                   	pop    %ebx
  801dcb:	5d                   	pop    %ebp
  801dcc:	c3                   	ret    

00801dcd <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  801dcd:	55                   	push   %ebp
  801dce:	89 e5                	mov    %esp,%ebp
  801dd0:	53                   	push   %ebx
  801dd1:	83 ec 14             	sub    $0x14,%esp
  801dd4:	8b 45 08             	mov    0x8(%ebp),%eax
  801dd7:	8b 55 0c             	mov    0xc(%ebp),%edx
  801dda:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  801ddd:	85 c0                	test   %eax,%eax
  801ddf:	74 44                	je     801e25 <devfile_write+0x58>
  801de1:	85 d2                	test   %edx,%edx
  801de3:	74 40                	je     801e25 <devfile_write+0x58>
  801de5:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  801deb:	77 38                	ja     801e25 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  801ded:	8b 40 0c             	mov    0xc(%eax),%eax
  801df0:	a3 00 40 80 00       	mov    %eax,0x804000
    fsipcbuf.write.req_n        = n;
  801df5:	89 1d 04 40 80 00    	mov    %ebx,0x804004
    memmove(fsipcbuf.write.req_buf, buf, n);
  801dfb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801dff:	89 54 24 04          	mov    %edx,0x4(%esp)
  801e03:	c7 04 24 08 40 80 00 	movl   $0x804008,(%esp)
  801e0a:	e8 76 ed ff ff       	call   800b85 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  801e0f:	ba 00 00 00 00       	mov    $0x0,%edx
  801e14:	b8 04 00 00 00       	mov    $0x4,%eax
  801e19:	e8 aa fe ff ff       	call   801cc8 <fsipc>
        return r;
    return n;
  801e1e:	85 c0                	test   %eax,%eax
  801e20:	0f 49 c3             	cmovns %ebx,%eax
  801e23:	eb 05                	jmp    801e2a <devfile_write+0x5d>
  801e25:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801e2a:	83 c4 14             	add    $0x14,%esp
  801e2d:	5b                   	pop    %ebx
  801e2e:	5d                   	pop    %ebp
  801e2f:	c3                   	ret    

00801e30 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  801e30:	55                   	push   %ebp
  801e31:	89 e5                	mov    %esp,%ebp
  801e33:	83 ec 18             	sub    $0x18,%esp
  801e36:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801e39:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801e3c:	8b 45 08             	mov    0x8(%ebp),%eax
  801e3f:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  801e42:	85 c0                	test   %eax,%eax
  801e44:	74 04                	je     801e4a <devfile_read+0x1a>
  801e46:	85 f6                	test   %esi,%esi
  801e48:	75 07                	jne    801e51 <devfile_read+0x21>
  801e4a:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801e4f:	eb 39                	jmp    801e8a <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  801e51:	8b 40 0c             	mov    0xc(%eax),%eax
  801e54:	a3 00 40 80 00       	mov    %eax,0x804000
  fsipcbuf.read.req_n         = n;
  801e59:	8b 45 10             	mov    0x10(%ebp),%eax
  801e5c:	a3 04 40 80 00       	mov    %eax,0x804004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  801e61:	ba 00 00 00 00       	mov    $0x0,%edx
  801e66:	b8 03 00 00 00       	mov    $0x3,%eax
  801e6b:	e8 58 fe ff ff       	call   801cc8 <fsipc>
  801e70:	89 c3                	mov    %eax,%ebx
  801e72:	85 c0                	test   %eax,%eax
  801e74:	78 14                	js     801e8a <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  801e76:	89 44 24 08          	mov    %eax,0x8(%esp)
  801e7a:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801e81:	00 
  801e82:	89 34 24             	mov    %esi,(%esp)
  801e85:	e8 fb ec ff ff       	call   800b85 <memmove>
  return r;
}
  801e8a:	89 d8                	mov    %ebx,%eax
  801e8c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801e8f:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801e92:	89 ec                	mov    %ebp,%esp
  801e94:	5d                   	pop    %ebp
  801e95:	c3                   	ret    

00801e96 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  801e96:	55                   	push   %ebp
  801e97:	89 e5                	mov    %esp,%ebp
  801e99:	53                   	push   %ebx
  801e9a:	83 ec 14             	sub    $0x14,%esp
  801e9d:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  801ea0:	89 1c 24             	mov    %ebx,(%esp)
  801ea3:	e8 d8 ea ff ff       	call   800980 <strlen>
  801ea8:	89 c2                	mov    %eax,%edx
  801eaa:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  801eaf:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  801eb5:	7f 1f                	jg     801ed6 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  801eb7:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801ebb:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  801ec2:	e8 03 eb ff ff       	call   8009ca <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  801ec7:	ba 00 00 00 00       	mov    $0x0,%edx
  801ecc:	b8 07 00 00 00       	mov    $0x7,%eax
  801ed1:	e8 f2 fd ff ff       	call   801cc8 <fsipc>
}
  801ed6:	83 c4 14             	add    $0x14,%esp
  801ed9:	5b                   	pop    %ebx
  801eda:	5d                   	pop    %ebp
  801edb:	c3                   	ret    

00801edc <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  801edc:	55                   	push   %ebp
  801edd:	89 e5                	mov    %esp,%ebp
  801edf:	83 ec 28             	sub    $0x28,%esp
  801ee2:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801ee5:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801ee8:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  801eeb:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801ef0:	85 f6                	test   %esi,%esi
  801ef2:	74 65                	je     801f59 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  801ef4:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  801efb:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801efe:	89 04 24             	mov    %eax,(%esp)
  801f01:	e8 75 f7 ff ff       	call   80167b <fd_alloc>
  801f06:	89 c3                	mov    %eax,%ebx
  801f08:	85 c0                	test   %eax,%eax
  801f0a:	78 4d                	js     801f59 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  801f0c:	89 74 24 04          	mov    %esi,0x4(%esp)
  801f10:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  801f17:	e8 ae ea ff ff       	call   8009ca <strcpy>
	fsipcbuf.open.req_omode = mode;
  801f1c:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f1f:	a3 00 44 80 00       	mov    %eax,0x804400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  801f24:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801f27:	b8 01 00 00 00       	mov    $0x1,%eax
  801f2c:	e8 97 fd ff ff       	call   801cc8 <fsipc>
  801f31:	89 c3                	mov    %eax,%ebx
  801f33:	85 c0                	test   %eax,%eax
  801f35:	79 15                	jns    801f4c <open+0x70>
    fd_close(f, 0);
  801f37:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801f3e:	00 
  801f3f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801f42:	89 04 24             	mov    %eax,(%esp)
  801f45:	e8 3a fb ff ff       	call   801a84 <fd_close>
    return r;
  801f4a:	eb 0d                	jmp    801f59 <open+0x7d>
  }
  return fd2num(f);
  801f4c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801f4f:	89 04 24             	mov    %eax,(%esp)
  801f52:	e8 f9 f6 ff ff       	call   801650 <fd2num>
  801f57:	89 c3                	mov    %eax,%ebx
}
  801f59:	89 d8                	mov    %ebx,%eax
  801f5b:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801f5e:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801f61:	89 ec                	mov    %ebp,%esp
  801f63:	5d                   	pop    %ebp
  801f64:	c3                   	ret    
  801f65:	00 00                	add    %al,(%eax)
	...

00801f68 <spawn>:
// argv: pointer to null-terminated array of pointers to strings,
// 	 which will be passed to the child as its command-line arguments.
// Returns child envid on success, < 0 on failure.
int
spawn(const char *prog, const char **argv)
{
  801f68:	55                   	push   %ebp
  801f69:	89 e5                	mov    %esp,%ebp
  801f6b:	57                   	push   %edi
  801f6c:	56                   	push   %esi
  801f6d:	53                   	push   %ebx
  801f6e:	81 ec 9c 02 00 00    	sub    $0x29c,%esp
	//   - Call sys_env_set_trapframe(child, &child_tf) to set up the
	//     correct initial eip and esp values in the child.
	//
	//   - Start the child process running with sys_env_set_status().

	if ((r = open(prog, O_RDONLY)) < 0)
  801f74:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801f7b:	00 
  801f7c:	8b 45 08             	mov    0x8(%ebp),%eax
  801f7f:	89 04 24             	mov    %eax,(%esp)
  801f82:	e8 55 ff ff ff       	call   801edc <open>
  801f87:	89 85 88 fd ff ff    	mov    %eax,-0x278(%ebp)
  801f8d:	89 c3                	mov    %eax,%ebx
  801f8f:	85 c0                	test   %eax,%eax
  801f91:	0f 88 e0 05 00 00    	js     802577 <spawn+0x60f>
	fd = r;

	// Read elf header
	elf = (struct Elf*) elf_buf;
	if (read(fd, elf_buf, sizeof(elf_buf)) != sizeof(elf_buf)
	    || elf->e_magic != ELF_MAGIC) {
  801f97:	c7 44 24 08 00 02 00 	movl   $0x200,0x8(%esp)
  801f9e:	00 
  801f9f:	8d 85 e8 fd ff ff    	lea    -0x218(%ebp),%eax
  801fa5:	89 44 24 04          	mov    %eax,0x4(%esp)
  801fa9:	89 1c 24             	mov    %ebx,(%esp)
  801fac:	e8 a2 f9 ff ff       	call   801953 <read>
		return r;
	fd = r;

	// Read elf header
	elf = (struct Elf*) elf_buf;
	if (read(fd, elf_buf, sizeof(elf_buf)) != sizeof(elf_buf)
  801fb1:	3d 00 02 00 00       	cmp    $0x200,%eax
  801fb6:	75 0c                	jne    801fc4 <spawn+0x5c>
	    || elf->e_magic != ELF_MAGIC) {
  801fb8:	81 bd e8 fd ff ff 7f 	cmpl   $0x464c457f,-0x218(%ebp)
  801fbf:	45 4c 46 
  801fc2:	74 36                	je     801ffa <spawn+0x92>
		close(fd);
  801fc4:	8b 85 88 fd ff ff    	mov    -0x278(%ebp),%eax
  801fca:	89 04 24             	mov    %eax,(%esp)
  801fcd:	e8 3a fb ff ff       	call   801b0c <close>
		cprintf("elf magic %08x want %08x\n", elf->e_magic, ELF_MAGIC);
  801fd2:	c7 44 24 08 7f 45 4c 	movl   $0x464c457f,0x8(%esp)
  801fd9:	46 
  801fda:	8b 85 e8 fd ff ff    	mov    -0x218(%ebp),%eax
  801fe0:	89 44 24 04          	mov    %eax,0x4(%esp)
  801fe4:	c7 04 24 28 3b 80 00 	movl   $0x803b28,(%esp)
  801feb:	e8 11 e3 ff ff       	call   800301 <cprintf>
  801ff0:	bb f2 ff ff ff       	mov    $0xfffffff2,%ebx
		return -E_NOT_EXEC;
  801ff5:	e9 7d 05 00 00       	jmp    802577 <spawn+0x60f>
  801ffa:	ba 07 00 00 00       	mov    $0x7,%edx
  801fff:	89 d0                	mov    %edx,%eax
  802001:	cd 30                	int    $0x30
  802003:	89 85 84 fd ff ff    	mov    %eax,-0x27c(%ebp)
	}

	// Create new child environment
	if ((r = sys_exofork()) < 0)
  802009:	85 c0                	test   %eax,%eax
  80200b:	0f 88 60 05 00 00    	js     802571 <spawn+0x609>
		return r;
	child = r;

	// Set up trap frame, including initial stack.
	child_tf = envs[ENVX(child)].env_tf;
  802011:	89 c6                	mov    %eax,%esi
  802013:	81 e6 ff 03 00 00    	and    $0x3ff,%esi
  802019:	6b f6 7c             	imul   $0x7c,%esi,%esi
  80201c:	8d bd a4 fd ff ff    	lea    -0x25c(%ebp),%edi
  802022:	81 c6 00 00 c0 ee    	add    $0xeec00000,%esi
  802028:	b9 11 00 00 00       	mov    $0x11,%ecx
  80202d:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	child_tf.tf_eip = elf->e_entry;
  80202f:	8b 85 00 fe ff ff    	mov    -0x200(%ebp),%eax
  802035:	89 85 d4 fd ff ff    	mov    %eax,-0x22c(%ebp)
	uintptr_t *argv_store;

	// Count the number of arguments (argc)
	// and the total amount of space needed for strings (string_size).
	string_size = 0;
	for (argc = 0; argv[argc] != 0; argc++)
  80203b:	8b 55 0c             	mov    0xc(%ebp),%edx
  80203e:	8b 02                	mov    (%edx),%eax
  802040:	bb 00 00 00 00       	mov    $0x0,%ebx
  802045:	be 00 00 00 00       	mov    $0x0,%esi
  80204a:	85 c0                	test   %eax,%eax
  80204c:	75 16                	jne    802064 <spawn+0xfc>
  80204e:	c7 85 7c fd ff ff 00 	movl   $0x0,-0x284(%ebp)
  802055:	00 00 00 
  802058:	c7 85 78 fd ff ff 00 	movl   $0x0,-0x288(%ebp)
  80205f:	00 00 00 
  802062:	eb 2c                	jmp    802090 <spawn+0x128>
  802064:	8b 7d 0c             	mov    0xc(%ebp),%edi
		string_size += strlen(argv[argc]) + 1;
  802067:	89 04 24             	mov    %eax,(%esp)
  80206a:	e8 11 e9 ff ff       	call   800980 <strlen>
  80206f:	8d 5c 18 01          	lea    0x1(%eax,%ebx,1),%ebx
	uintptr_t *argv_store;

	// Count the number of arguments (argc)
	// and the total amount of space needed for strings (string_size).
	string_size = 0;
	for (argc = 0; argv[argc] != 0; argc++)
  802073:	83 c6 01             	add    $0x1,%esi
  802076:	8d 14 b5 00 00 00 00 	lea    0x0(,%esi,4),%edx
  80207d:	8b 04 b7             	mov    (%edi,%esi,4),%eax
  802080:	85 c0                	test   %eax,%eax
  802082:	75 e3                	jne    802067 <spawn+0xff>
  802084:	89 95 7c fd ff ff    	mov    %edx,-0x284(%ebp)
  80208a:	89 b5 78 fd ff ff    	mov    %esi,-0x288(%ebp)
	// Determine where to place the strings and the argv array.
	// Set up pointers into the temporary page 'UTEMP'; we'll map a page
	// there later, then remap that page into the child environment
	// at (USTACKTOP - PGSIZE).
	// strings is the topmost thing on the stack.
	string_store = (char*) UTEMP + PGSIZE - string_size;
  802090:	f7 db                	neg    %ebx
  802092:	8d bb 00 10 40 00    	lea    0x401000(%ebx),%edi
	// argv is below that.  There's one argument pointer per argument, plus
	// a null pointer.
	argv_store = (uintptr_t*) (ROUNDDOWN(string_store, 4) - 4 * (argc + 1));
  802098:	89 fa                	mov    %edi,%edx
  80209a:	83 e2 fc             	and    $0xfffffffc,%edx
  80209d:	89 f0                	mov    %esi,%eax
  80209f:	f7 d0                	not    %eax
  8020a1:	8d 04 82             	lea    (%edx,%eax,4),%eax
  8020a4:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
	
	// Make sure that argv, strings, and the 2 words that hold 'argc'
	// and 'argv' themselves will all fit in a single stack page.
	if ((void*) (argv_store - 2) < (void*) UTEMP)
  8020aa:	83 e8 08             	sub    $0x8,%eax
  8020ad:	89 85 80 fd ff ff    	mov    %eax,-0x280(%ebp)
	return child;

error:
	sys_env_destroy(child);
	close(fd);
	return r;
  8020b3:	bb fc ff ff ff       	mov    $0xfffffffc,%ebx
	// a null pointer.
	argv_store = (uintptr_t*) (ROUNDDOWN(string_store, 4) - 4 * (argc + 1));
	
	// Make sure that argv, strings, and the 2 words that hold 'argc'
	// and 'argv' themselves will all fit in a single stack page.
	if ((void*) (argv_store - 2) < (void*) UTEMP)
  8020b8:	3d ff ff 3f 00       	cmp    $0x3fffff,%eax
  8020bd:	0f 86 b4 04 00 00    	jbe    802577 <spawn+0x60f>
		return -E_NO_MEM;

	// Allocate the single stack page at UTEMP.
	if ((r = sys_page_alloc(0, (void*) UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
  8020c3:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  8020ca:	00 
  8020cb:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  8020d2:	00 
  8020d3:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8020da:	e8 47 f0 ff ff       	call   801126 <sys_page_alloc>
  8020df:	89 c3                	mov    %eax,%ebx
  8020e1:	85 c0                	test   %eax,%eax
  8020e3:	0f 88 8e 04 00 00    	js     802577 <spawn+0x60f>
	//	  (Again, argv should use an address valid in the child's
	//	  environment.)
	//
	//	* Set *init_esp to the initial stack pointer for the child,
	//	  (Again, use an address valid in the child's environment.)
	for (i = 0; i < argc; i++) {
  8020e9:	85 f6                	test   %esi,%esi
  8020eb:	7e 46                	jle    802133 <spawn+0x1cb>
  8020ed:	bb 00 00 00 00       	mov    $0x0,%ebx
  8020f2:	89 b5 8c fd ff ff    	mov    %esi,-0x274(%ebp)
  8020f8:	8b 75 0c             	mov    0xc(%ebp),%esi
		argv_store[i] = UTEMP2USTACK(string_store);
  8020fb:	8d 87 00 d0 7f ee    	lea    -0x11803000(%edi),%eax
  802101:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  802107:	89 04 9a             	mov    %eax,(%edx,%ebx,4)
		strcpy(string_store, argv[i]);
  80210a:	8b 04 9e             	mov    (%esi,%ebx,4),%eax
  80210d:	89 44 24 04          	mov    %eax,0x4(%esp)
  802111:	89 3c 24             	mov    %edi,(%esp)
  802114:	e8 b1 e8 ff ff       	call   8009ca <strcpy>
		string_store += strlen(argv[i]) + 1;
  802119:	8b 04 9e             	mov    (%esi,%ebx,4),%eax
  80211c:	89 04 24             	mov    %eax,(%esp)
  80211f:	e8 5c e8 ff ff       	call   800980 <strlen>
  802124:	8d 7c 38 01          	lea    0x1(%eax,%edi,1),%edi
	//	  (Again, argv should use an address valid in the child's
	//	  environment.)
	//
	//	* Set *init_esp to the initial stack pointer for the child,
	//	  (Again, use an address valid in the child's environment.)
	for (i = 0; i < argc; i++) {
  802128:	83 c3 01             	add    $0x1,%ebx
  80212b:	3b 9d 8c fd ff ff    	cmp    -0x274(%ebp),%ebx
  802131:	7c c8                	jl     8020fb <spawn+0x193>
		argv_store[i] = UTEMP2USTACK(string_store);
		strcpy(string_store, argv[i]);
		string_store += strlen(argv[i]) + 1;
	}
	argv_store[argc] = 0;
  802133:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  802139:	8b 85 7c fd ff ff    	mov    -0x284(%ebp),%eax
  80213f:	c7 04 02 00 00 00 00 	movl   $0x0,(%edx,%eax,1)
	assert(string_store == (char*)UTEMP + PGSIZE);
  802146:	81 ff 00 10 40 00    	cmp    $0x401000,%edi
  80214c:	74 24                	je     802172 <spawn+0x20a>
  80214e:	c7 44 24 0c c8 3b 80 	movl   $0x803bc8,0xc(%esp)
  802155:	00 
  802156:	c7 44 24 08 42 3b 80 	movl   $0x803b42,0x8(%esp)
  80215d:	00 
  80215e:	c7 44 24 04 d9 00 00 	movl   $0xd9,0x4(%esp)
  802165:	00 
  802166:	c7 04 24 57 3b 80 00 	movl   $0x803b57,(%esp)
  80216d:	e8 ca e0 ff ff       	call   80023c <_panic>

	argv_store[-1] = UTEMP2USTACK(argv_store);
  802172:	8b 85 94 fd ff ff    	mov    -0x26c(%ebp),%eax
  802178:	2d 00 30 80 11       	sub    $0x11803000,%eax
  80217d:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  802183:	89 42 fc             	mov    %eax,-0x4(%edx)
	argv_store[-2] = argc;
  802186:	8b 95 78 fd ff ff    	mov    -0x288(%ebp),%edx
  80218c:	8b 85 80 fd ff ff    	mov    -0x280(%ebp),%eax
  802192:	89 10                	mov    %edx,(%eax)

	*init_esp = UTEMP2USTACK(&argv_store[-2]);
  802194:	8b 85 94 fd ff ff    	mov    -0x26c(%ebp),%eax
  80219a:	2d 08 30 80 11       	sub    $0x11803008,%eax
  80219f:	89 85 e0 fd ff ff    	mov    %eax,-0x220(%ebp)

	// After completing the stack, map it into the child's address space
	// and unmap it from ours!
	if ((r = sys_page_map(0, UTEMP, child, (void*) (USTACKTOP - PGSIZE), PTE_P | PTE_U | PTE_W)) < 0)
  8021a5:	c7 44 24 10 07 00 00 	movl   $0x7,0x10(%esp)
  8021ac:	00 
  8021ad:	c7 44 24 0c 00 d0 bf 	movl   $0xeebfd000,0xc(%esp)
  8021b4:	ee 
  8021b5:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  8021bb:	89 44 24 08          	mov    %eax,0x8(%esp)
  8021bf:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  8021c6:	00 
  8021c7:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8021ce:	e8 f5 ee ff ff       	call   8010c8 <sys_page_map>
  8021d3:	89 c3                	mov    %eax,%ebx
  8021d5:	85 c0                	test   %eax,%eax
  8021d7:	78 1a                	js     8021f3 <spawn+0x28b>
		goto error;
	if ((r = sys_page_unmap(0, UTEMP)) < 0)
  8021d9:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  8021e0:	00 
  8021e1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8021e8:	e8 7d ee ff ff       	call   80106a <sys_page_unmap>
  8021ed:	89 c3                	mov    %eax,%ebx
  8021ef:	85 c0                	test   %eax,%eax
  8021f1:	79 19                	jns    80220c <spawn+0x2a4>
		goto error;

	return 0;

error:
	sys_page_unmap(0, UTEMP);
  8021f3:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  8021fa:	00 
  8021fb:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802202:	e8 63 ee ff ff       	call   80106a <sys_page_unmap>
  802207:	e9 6b 03 00 00       	jmp    802577 <spawn+0x60f>

	if ((r = init_stack(child, argv, &child_tf.tf_esp)) < 0)
		return r;

	// Set up program segments as defined in ELF header.
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
  80220c:	8b 85 04 fe ff ff    	mov    -0x1fc(%ebp),%eax
	for (i = 0; i < elf->e_phnum; i++, ph++) {
  802212:	66 83 bd 14 fe ff ff 	cmpw   $0x0,-0x1ec(%ebp)
  802219:	00 
  80221a:	0f 84 e4 01 00 00    	je     802404 <spawn+0x49c>

	if ((r = init_stack(child, argv, &child_tf.tf_esp)) < 0)
		return r;

	// Set up program segments as defined in ELF header.
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
  802220:	8d 84 05 e8 fd ff ff 	lea    -0x218(%ebp,%eax,1),%eax
  802227:	89 85 80 fd ff ff    	mov    %eax,-0x280(%ebp)
  80222d:	c7 85 7c fd ff ff 00 	movl   $0x0,-0x284(%ebp)
  802234:	00 00 00 
	for (i = 0; i < elf->e_phnum; i++, ph++) {
		if (ph->p_type != ELF_PROG_LOAD)
  802237:	8b 95 80 fd ff ff    	mov    -0x280(%ebp),%edx
  80223d:	83 3a 01             	cmpl   $0x1,(%edx)
  802240:	0f 85 9c 01 00 00    	jne    8023e2 <spawn+0x47a>
			continue;
		perm = PTE_P | PTE_U;
		if (ph->p_flags & ELF_PROG_FLAG_WRITE)
  802246:	8b 42 18             	mov    0x18(%edx),%eax
  802249:	83 e0 02             	and    $0x2,%eax
  80224c:	83 f8 01             	cmp    $0x1,%eax
  80224f:	19 c0                	sbb    %eax,%eax
  802251:	83 e0 fe             	and    $0xfffffffe,%eax
  802254:	83 c0 07             	add    $0x7,%eax
  802257:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
			perm |= PTE_W;
		if ((r = map_segment(child, ph->p_va, ph->p_memsz, 
  80225d:	8b 52 04             	mov    0x4(%edx),%edx
  802260:	89 95 78 fd ff ff    	mov    %edx,-0x288(%ebp)
  802266:	8b 85 80 fd ff ff    	mov    -0x280(%ebp),%eax
  80226c:	8b 58 10             	mov    0x10(%eax),%ebx
  80226f:	8b 50 14             	mov    0x14(%eax),%edx
  802272:	89 95 8c fd ff ff    	mov    %edx,-0x274(%ebp)
  802278:	8b 40 08             	mov    0x8(%eax),%eax
  80227b:	89 85 90 fd ff ff    	mov    %eax,-0x270(%ebp)
	int i, r;
	void *blk;

	//cprintf("map_segment %x+%x\n", va, memsz);

	if ((i = PGOFF(va))) {
  802281:	25 ff 0f 00 00       	and    $0xfff,%eax
  802286:	74 16                	je     80229e <spawn+0x336>
		va -= i;
  802288:	29 85 90 fd ff ff    	sub    %eax,-0x270(%ebp)
		memsz += i;
  80228e:	01 c2                	add    %eax,%edx
  802290:	89 95 8c fd ff ff    	mov    %edx,-0x274(%ebp)
		filesz += i;
  802296:	01 c3                	add    %eax,%ebx
		fileoffset -= i;
  802298:	29 85 78 fd ff ff    	sub    %eax,-0x288(%ebp)
	}

	for (i = 0; i < memsz; i += PGSIZE) {
  80229e:	83 bd 8c fd ff ff 00 	cmpl   $0x0,-0x274(%ebp)
  8022a5:	0f 84 37 01 00 00    	je     8023e2 <spawn+0x47a>
  8022ab:	bf 00 00 00 00       	mov    $0x0,%edi
  8022b0:	be 00 00 00 00       	mov    $0x0,%esi
		if (i >= filesz) {
  8022b5:	39 fb                	cmp    %edi,%ebx
  8022b7:	77 31                	ja     8022ea <spawn+0x382>
			// allocate a blank page
			if ((r = sys_page_alloc(child, (void*) (va + i), perm)) < 0)
  8022b9:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  8022bf:	89 54 24 08          	mov    %edx,0x8(%esp)
  8022c3:	03 bd 90 fd ff ff    	add    -0x270(%ebp),%edi
  8022c9:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8022cd:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  8022d3:	89 04 24             	mov    %eax,(%esp)
  8022d6:	e8 4b ee ff ff       	call   801126 <sys_page_alloc>
  8022db:	85 c0                	test   %eax,%eax
  8022dd:	0f 89 eb 00 00 00    	jns    8023ce <spawn+0x466>
  8022e3:	89 c3                	mov    %eax,%ebx
  8022e5:	e9 69 02 00 00       	jmp    802553 <spawn+0x5eb>
				return r;
		} else {
			// from file
			if ((r = sys_page_alloc(0, UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
  8022ea:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  8022f1:	00 
  8022f2:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  8022f9:	00 
  8022fa:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802301:	e8 20 ee ff ff       	call   801126 <sys_page_alloc>
  802306:	85 c0                	test   %eax,%eax
  802308:	0f 88 3b 02 00 00    	js     802549 <spawn+0x5e1>
				return r;
			if ((r = seek(fd, fileoffset + i)) < 0)
  80230e:	8b 85 78 fd ff ff    	mov    -0x288(%ebp),%eax
  802314:	8d 04 06             	lea    (%esi,%eax,1),%eax
  802317:	89 44 24 04          	mov    %eax,0x4(%esp)
  80231b:	8b 95 88 fd ff ff    	mov    -0x278(%ebp),%edx
  802321:	89 14 24             	mov    %edx,(%esp)
  802324:	e8 0c f4 ff ff       	call   801735 <seek>
  802329:	85 c0                	test   %eax,%eax
  80232b:	0f 88 1c 02 00 00    	js     80254d <spawn+0x5e5>
				return r;
			if ((r = read(fd, UTEMP, MIN(PGSIZE, filesz-i))) < 0)
  802331:	89 d8                	mov    %ebx,%eax
  802333:	29 f8                	sub    %edi,%eax
  802335:	3d 00 10 00 00       	cmp    $0x1000,%eax
  80233a:	ba 00 10 00 00       	mov    $0x1000,%edx
  80233f:	0f 47 c2             	cmova  %edx,%eax
  802342:	89 44 24 08          	mov    %eax,0x8(%esp)
  802346:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  80234d:	00 
  80234e:	8b 85 88 fd ff ff    	mov    -0x278(%ebp),%eax
  802354:	89 04 24             	mov    %eax,(%esp)
  802357:	e8 f7 f5 ff ff       	call   801953 <read>
  80235c:	85 c0                	test   %eax,%eax
  80235e:	0f 88 ed 01 00 00    	js     802551 <spawn+0x5e9>
				return r;
			if ((r = sys_page_map(0, UTEMP, child, (void*) (va + i), perm)) < 0)
  802364:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  80236a:	89 54 24 10          	mov    %edx,0x10(%esp)
  80236e:	03 bd 90 fd ff ff    	add    -0x270(%ebp),%edi
  802374:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  802378:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  80237e:	89 44 24 08          	mov    %eax,0x8(%esp)
  802382:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  802389:	00 
  80238a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802391:	e8 32 ed ff ff       	call   8010c8 <sys_page_map>
  802396:	85 c0                	test   %eax,%eax
  802398:	79 20                	jns    8023ba <spawn+0x452>
				panic("spawn: sys_page_map data: %e", r);
  80239a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80239e:	c7 44 24 08 63 3b 80 	movl   $0x803b63,0x8(%esp)
  8023a5:	00 
  8023a6:	c7 44 24 04 0c 01 00 	movl   $0x10c,0x4(%esp)
  8023ad:	00 
  8023ae:	c7 04 24 57 3b 80 00 	movl   $0x803b57,(%esp)
  8023b5:	e8 82 de ff ff       	call   80023c <_panic>
			sys_page_unmap(0, UTEMP);
  8023ba:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  8023c1:	00 
  8023c2:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8023c9:	e8 9c ec ff ff       	call   80106a <sys_page_unmap>
		memsz += i;
		filesz += i;
		fileoffset -= i;
	}

	for (i = 0; i < memsz; i += PGSIZE) {
  8023ce:	81 c6 00 10 00 00    	add    $0x1000,%esi
  8023d4:	89 f7                	mov    %esi,%edi
  8023d6:	39 b5 8c fd ff ff    	cmp    %esi,-0x274(%ebp)
  8023dc:	0f 87 d3 fe ff ff    	ja     8022b5 <spawn+0x34d>
	if ((r = init_stack(child, argv, &child_tf.tf_esp)) < 0)
		return r;

	// Set up program segments as defined in ELF header.
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
	for (i = 0; i < elf->e_phnum; i++, ph++) {
  8023e2:	83 85 7c fd ff ff 01 	addl   $0x1,-0x284(%ebp)
  8023e9:	0f b7 85 14 fe ff ff 	movzwl -0x1ec(%ebp),%eax
  8023f0:	3b 85 7c fd ff ff    	cmp    -0x284(%ebp),%eax
  8023f6:	7e 0c                	jle    802404 <spawn+0x49c>
  8023f8:	83 85 80 fd ff ff 20 	addl   $0x20,-0x280(%ebp)
  8023ff:	e9 33 fe ff ff       	jmp    802237 <spawn+0x2cf>
			perm |= PTE_W;
		if ((r = map_segment(child, ph->p_va, ph->p_memsz, 
				     fd, ph->p_filesz, ph->p_offset, perm)) < 0)
			goto error;
	}
	close(fd);
  802404:	8b 95 88 fd ff ff    	mov    -0x278(%ebp),%edx
  80240a:	89 14 24             	mov    %edx,(%esp)
  80240d:	e8 fa f6 ff ff       	call   801b0c <close>
static int
copy_shared_pages(envid_t child)
{
    int va;
    int r=0;
    envid_t cur = sys_getenvid();
  802412:	e8 a2 ed ff ff       	call   8011b9 <sys_getenvid>
  802417:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
  80241d:	b8 00 00 00 00       	mov    $0x0,%eax
  802422:	bb 00 00 00 00       	mov    $0x0,%ebx
    for (va=0;va<USTACKTOP; va+=PGSIZE) {
        if (((vpd[PDX(va)] & PTE_P) && (vpt[VPN(va)] & PTE_P) && (vpt[VPN(va)] & PTE_SHARE))) {
  802427:	be 00 d0 7b ef       	mov    $0xef7bd000,%esi
  80242c:	bf 00 00 40 ef       	mov    $0xef400000,%edi
  802431:	89 c2                	mov    %eax,%edx
  802433:	89 d1                	mov    %edx,%ecx
  802435:	c1 e9 16             	shr    $0x16,%ecx
  802438:	8b 0c 8e             	mov    (%esi,%ecx,4),%ecx
  80243b:	f6 c1 01             	test   $0x1,%cl
  80243e:	74 5f                	je     80249f <spawn+0x537>
  802440:	c1 ea 0c             	shr    $0xc,%edx
  802443:	8b 0c 97             	mov    (%edi,%edx,4),%ecx
  802446:	f6 c1 01             	test   $0x1,%cl
  802449:	74 54                	je     80249f <spawn+0x537>
  80244b:	8b 0c 97             	mov    (%edi,%edx,4),%ecx
  80244e:	f6 c5 04             	test   $0x4,%ch
  802451:	74 4c                	je     80249f <spawn+0x537>
            if((r=sys_page_map(cur, (void *)(va), child, (void *)(va), vpt[VPN(va)]&PTE_USER))<0)
  802453:	8b 04 97             	mov    (%edi,%edx,4),%eax
  802456:	25 07 0e 00 00       	and    $0xe07,%eax
  80245b:	89 44 24 10          	mov    %eax,0x10(%esp)
  80245f:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  802463:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  802469:	89 44 24 08          	mov    %eax,0x8(%esp)
  80246d:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802471:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  802477:	89 14 24             	mov    %edx,(%esp)
  80247a:	e8 49 ec ff ff       	call   8010c8 <sys_page_map>
  80247f:	85 c0                	test   %eax,%eax
  802481:	79 1c                	jns    80249f <spawn+0x537>
                panic("copy_shared_pages: error sharing\n");
  802483:	c7 44 24 08 f0 3b 80 	movl   $0x803bf0,0x8(%esp)
  80248a:	00 
  80248b:	c7 44 24 04 1d 01 00 	movl   $0x11d,0x4(%esp)
  802492:	00 
  802493:	c7 04 24 57 3b 80 00 	movl   $0x803b57,(%esp)
  80249a:	e8 9d dd ff ff       	call   80023c <_panic>
copy_shared_pages(envid_t child)
{
    int va;
    int r=0;
    envid_t cur = sys_getenvid();
    for (va=0;va<USTACKTOP; va+=PGSIZE) {
  80249f:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  8024a5:	89 da                	mov    %ebx,%edx
  8024a7:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  8024ad:	75 84                	jne    802433 <spawn+0x4cb>
	}
	close(fd);
	fd = -1;

	// Copy shared library state.
	if ((r = copy_shared_pages(child)) < 0)
  8024af:	85 c0                	test   %eax,%eax
  8024b1:	79 20                	jns    8024d3 <spawn+0x56b>
		panic("copy_shared_pages: %e", r);
  8024b3:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8024b7:	c7 44 24 08 80 3b 80 	movl   $0x803b80,0x8(%esp)
  8024be:	00 
  8024bf:	c7 44 24 04 82 00 00 	movl   $0x82,0x4(%esp)
  8024c6:	00 
  8024c7:	c7 04 24 57 3b 80 00 	movl   $0x803b57,(%esp)
  8024ce:	e8 69 dd ff ff       	call   80023c <_panic>

	if ((r = sys_env_set_trapframe(child, &child_tf)) < 0)
  8024d3:	8d 85 a4 fd ff ff    	lea    -0x25c(%ebp),%eax
  8024d9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8024dd:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  8024e3:	89 04 24             	mov    %eax,(%esp)
  8024e6:	e8 c3 ea ff ff       	call   800fae <sys_env_set_trapframe>
  8024eb:	85 c0                	test   %eax,%eax
  8024ed:	79 20                	jns    80250f <spawn+0x5a7>
		panic("sys_env_set_trapframe: %e", r);
  8024ef:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8024f3:	c7 44 24 08 96 3b 80 	movl   $0x803b96,0x8(%esp)
  8024fa:	00 
  8024fb:	c7 44 24 04 85 00 00 	movl   $0x85,0x4(%esp)
  802502:	00 
  802503:	c7 04 24 57 3b 80 00 	movl   $0x803b57,(%esp)
  80250a:	e8 2d dd ff ff       	call   80023c <_panic>

	if ((r = sys_env_set_status(child, ENV_RUNNABLE)) < 0)
  80250f:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  802516:	00 
  802517:	8b 95 84 fd ff ff    	mov    -0x27c(%ebp),%edx
  80251d:	89 14 24             	mov    %edx,(%esp)
  802520:	e8 e7 ea ff ff       	call   80100c <sys_env_set_status>
  802525:	85 c0                	test   %eax,%eax
  802527:	79 48                	jns    802571 <spawn+0x609>
		panic("sys_env_set_status: %e", r);
  802529:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80252d:	c7 44 24 08 b0 3b 80 	movl   $0x803bb0,0x8(%esp)
  802534:	00 
  802535:	c7 44 24 04 88 00 00 	movl   $0x88,0x4(%esp)
  80253c:	00 
  80253d:	c7 04 24 57 3b 80 00 	movl   $0x803b57,(%esp)
  802544:	e8 f3 dc ff ff       	call   80023c <_panic>
  802549:	89 c3                	mov    %eax,%ebx
  80254b:	eb 06                	jmp    802553 <spawn+0x5eb>
  80254d:	89 c3                	mov    %eax,%ebx
  80254f:	eb 02                	jmp    802553 <spawn+0x5eb>
  802551:	89 c3                	mov    %eax,%ebx

	return child;

error:
	sys_env_destroy(child);
  802553:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  802559:	89 04 24             	mov    %eax,(%esp)
  80255c:	e8 8c ec ff ff       	call   8011ed <sys_env_destroy>
	close(fd);
  802561:	8b 95 88 fd ff ff    	mov    -0x278(%ebp),%edx
  802567:	89 14 24             	mov    %edx,(%esp)
  80256a:	e8 9d f5 ff ff       	call   801b0c <close>
	return r;
  80256f:	eb 06                	jmp    802577 <spawn+0x60f>
  802571:	8b 9d 84 fd ff ff    	mov    -0x27c(%ebp),%ebx
}
  802577:	89 d8                	mov    %ebx,%eax
  802579:	81 c4 9c 02 00 00    	add    $0x29c,%esp
  80257f:	5b                   	pop    %ebx
  802580:	5e                   	pop    %esi
  802581:	5f                   	pop    %edi
  802582:	5d                   	pop    %ebp
  802583:	c3                   	ret    

00802584 <spawnl>:

// Spawn, taking command-line arguments array directly on the stack.
int
spawnl(const char *prog, const char *arg0, ...)
{
  802584:	55                   	push   %ebp
  802585:	89 e5                	mov    %esp,%ebp
  802587:	83 ec 18             	sub    $0x18,%esp
	return spawn(prog, &arg0);
  80258a:	8d 45 0c             	lea    0xc(%ebp),%eax
  80258d:	89 44 24 04          	mov    %eax,0x4(%esp)
  802591:	8b 45 08             	mov    0x8(%ebp),%eax
  802594:	89 04 24             	mov    %eax,(%esp)
  802597:	e8 cc f9 ff ff       	call   801f68 <spawn>
}
  80259c:	c9                   	leave  
  80259d:	c3                   	ret    
	...

008025a0 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  8025a0:	55                   	push   %ebp
  8025a1:	89 e5                	mov    %esp,%ebp
  8025a3:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  8025a6:	c7 44 24 04 12 3c 80 	movl   $0x803c12,0x4(%esp)
  8025ad:	00 
  8025ae:	8b 45 0c             	mov    0xc(%ebp),%eax
  8025b1:	89 04 24             	mov    %eax,(%esp)
  8025b4:	e8 11 e4 ff ff       	call   8009ca <strcpy>
	return 0;
}
  8025b9:	b8 00 00 00 00       	mov    $0x0,%eax
  8025be:	c9                   	leave  
  8025bf:	c3                   	ret    

008025c0 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  8025c0:	55                   	push   %ebp
  8025c1:	89 e5                	mov    %esp,%ebp
  8025c3:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  8025c6:	8b 45 08             	mov    0x8(%ebp),%eax
  8025c9:	8b 40 0c             	mov    0xc(%eax),%eax
  8025cc:	89 04 24             	mov    %eax,(%esp)
  8025cf:	e8 9d 02 00 00       	call   802871 <nsipc_close>
}
  8025d4:	c9                   	leave  
  8025d5:	c3                   	ret    

008025d6 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  8025d6:	55                   	push   %ebp
  8025d7:	89 e5                	mov    %esp,%ebp
  8025d9:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  8025dc:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8025e3:	00 
  8025e4:	8b 45 10             	mov    0x10(%ebp),%eax
  8025e7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8025eb:	8b 45 0c             	mov    0xc(%ebp),%eax
  8025ee:	89 44 24 04          	mov    %eax,0x4(%esp)
  8025f2:	8b 45 08             	mov    0x8(%ebp),%eax
  8025f5:	8b 40 0c             	mov    0xc(%eax),%eax
  8025f8:	89 04 24             	mov    %eax,(%esp)
  8025fb:	e8 ad 02 00 00       	call   8028ad <nsipc_send>
}
  802600:	c9                   	leave  
  802601:	c3                   	ret    

00802602 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  802602:	55                   	push   %ebp
  802603:	89 e5                	mov    %esp,%ebp
  802605:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  802608:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80260f:	00 
  802610:	8b 45 10             	mov    0x10(%ebp),%eax
  802613:	89 44 24 08          	mov    %eax,0x8(%esp)
  802617:	8b 45 0c             	mov    0xc(%ebp),%eax
  80261a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80261e:	8b 45 08             	mov    0x8(%ebp),%eax
  802621:	8b 40 0c             	mov    0xc(%eax),%eax
  802624:	89 04 24             	mov    %eax,(%esp)
  802627:	e8 f4 02 00 00       	call   802920 <nsipc_recv>
}
  80262c:	c9                   	leave  
  80262d:	c3                   	ret    

0080262e <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  80262e:	55                   	push   %ebp
  80262f:	89 e5                	mov    %esp,%ebp
  802631:	56                   	push   %esi
  802632:	53                   	push   %ebx
  802633:	83 ec 20             	sub    $0x20,%esp
  802636:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802638:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80263b:	89 04 24             	mov    %eax,(%esp)
  80263e:	e8 38 f0 ff ff       	call   80167b <fd_alloc>
  802643:	89 c3                	mov    %eax,%ebx
  802645:	85 c0                	test   %eax,%eax
  802647:	78 21                	js     80266a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  802649:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802650:	00 
  802651:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802654:	89 44 24 04          	mov    %eax,0x4(%esp)
  802658:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80265f:	e8 c2 ea ff ff       	call   801126 <sys_page_alloc>
  802664:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802666:	85 c0                	test   %eax,%eax
  802668:	79 0a                	jns    802674 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  80266a:	89 34 24             	mov    %esi,(%esp)
  80266d:	e8 ff 01 00 00       	call   802871 <nsipc_close>
		return r;
  802672:	eb 28                	jmp    80269c <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  802674:	8b 15 28 70 80 00    	mov    0x807028,%edx
  80267a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80267d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  80267f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802682:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  802689:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80268c:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  80268f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802692:	89 04 24             	mov    %eax,(%esp)
  802695:	e8 b6 ef ff ff       	call   801650 <fd2num>
  80269a:	89 c3                	mov    %eax,%ebx
}
  80269c:	89 d8                	mov    %ebx,%eax
  80269e:	83 c4 20             	add    $0x20,%esp
  8026a1:	5b                   	pop    %ebx
  8026a2:	5e                   	pop    %esi
  8026a3:	5d                   	pop    %ebp
  8026a4:	c3                   	ret    

008026a5 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  8026a5:	55                   	push   %ebp
  8026a6:	89 e5                	mov    %esp,%ebp
  8026a8:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  8026ab:	8b 45 10             	mov    0x10(%ebp),%eax
  8026ae:	89 44 24 08          	mov    %eax,0x8(%esp)
  8026b2:	8b 45 0c             	mov    0xc(%ebp),%eax
  8026b5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8026b9:	8b 45 08             	mov    0x8(%ebp),%eax
  8026bc:	89 04 24             	mov    %eax,(%esp)
  8026bf:	e8 61 01 00 00       	call   802825 <nsipc_socket>
  8026c4:	85 c0                	test   %eax,%eax
  8026c6:	78 05                	js     8026cd <socket+0x28>
		return r;
	return alloc_sockfd(r);
  8026c8:	e8 61 ff ff ff       	call   80262e <alloc_sockfd>
}
  8026cd:	c9                   	leave  
  8026ce:	66 90                	xchg   %ax,%ax
  8026d0:	c3                   	ret    

008026d1 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  8026d1:	55                   	push   %ebp
  8026d2:	89 e5                	mov    %esp,%ebp
  8026d4:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  8026d7:	8d 55 f4             	lea    -0xc(%ebp),%edx
  8026da:	89 54 24 04          	mov    %edx,0x4(%esp)
  8026de:	89 04 24             	mov    %eax,(%esp)
  8026e1:	e8 07 f0 ff ff       	call   8016ed <fd_lookup>
  8026e6:	85 c0                	test   %eax,%eax
  8026e8:	78 15                	js     8026ff <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  8026ea:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8026ed:	8b 0a                	mov    (%edx),%ecx
  8026ef:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8026f4:	3b 0d 28 70 80 00    	cmp    0x807028,%ecx
  8026fa:	75 03                	jne    8026ff <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  8026fc:	8b 42 0c             	mov    0xc(%edx),%eax
}
  8026ff:	c9                   	leave  
  802700:	c3                   	ret    

00802701 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  802701:	55                   	push   %ebp
  802702:	89 e5                	mov    %esp,%ebp
  802704:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802707:	8b 45 08             	mov    0x8(%ebp),%eax
  80270a:	e8 c2 ff ff ff       	call   8026d1 <fd2sockid>
  80270f:	85 c0                	test   %eax,%eax
  802711:	78 0f                	js     802722 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  802713:	8b 55 0c             	mov    0xc(%ebp),%edx
  802716:	89 54 24 04          	mov    %edx,0x4(%esp)
  80271a:	89 04 24             	mov    %eax,(%esp)
  80271d:	e8 2d 01 00 00       	call   80284f <nsipc_listen>
}
  802722:	c9                   	leave  
  802723:	c3                   	ret    

00802724 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802724:	55                   	push   %ebp
  802725:	89 e5                	mov    %esp,%ebp
  802727:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  80272a:	8b 45 08             	mov    0x8(%ebp),%eax
  80272d:	e8 9f ff ff ff       	call   8026d1 <fd2sockid>
  802732:	85 c0                	test   %eax,%eax
  802734:	78 16                	js     80274c <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  802736:	8b 55 10             	mov    0x10(%ebp),%edx
  802739:	89 54 24 08          	mov    %edx,0x8(%esp)
  80273d:	8b 55 0c             	mov    0xc(%ebp),%edx
  802740:	89 54 24 04          	mov    %edx,0x4(%esp)
  802744:	89 04 24             	mov    %eax,(%esp)
  802747:	e8 54 02 00 00       	call   8029a0 <nsipc_connect>
}
  80274c:	c9                   	leave  
  80274d:	c3                   	ret    

0080274e <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  80274e:	55                   	push   %ebp
  80274f:	89 e5                	mov    %esp,%ebp
  802751:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802754:	8b 45 08             	mov    0x8(%ebp),%eax
  802757:	e8 75 ff ff ff       	call   8026d1 <fd2sockid>
  80275c:	85 c0                	test   %eax,%eax
  80275e:	78 0f                	js     80276f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  802760:	8b 55 0c             	mov    0xc(%ebp),%edx
  802763:	89 54 24 04          	mov    %edx,0x4(%esp)
  802767:	89 04 24             	mov    %eax,(%esp)
  80276a:	e8 1c 01 00 00       	call   80288b <nsipc_shutdown>
}
  80276f:	c9                   	leave  
  802770:	c3                   	ret    

00802771 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  802771:	55                   	push   %ebp
  802772:	89 e5                	mov    %esp,%ebp
  802774:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802777:	8b 45 08             	mov    0x8(%ebp),%eax
  80277a:	e8 52 ff ff ff       	call   8026d1 <fd2sockid>
  80277f:	85 c0                	test   %eax,%eax
  802781:	78 16                	js     802799 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  802783:	8b 55 10             	mov    0x10(%ebp),%edx
  802786:	89 54 24 08          	mov    %edx,0x8(%esp)
  80278a:	8b 55 0c             	mov    0xc(%ebp),%edx
  80278d:	89 54 24 04          	mov    %edx,0x4(%esp)
  802791:	89 04 24             	mov    %eax,(%esp)
  802794:	e8 46 02 00 00       	call   8029df <nsipc_bind>
}
  802799:	c9                   	leave  
  80279a:	c3                   	ret    

0080279b <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80279b:	55                   	push   %ebp
  80279c:	89 e5                	mov    %esp,%ebp
  80279e:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8027a1:	8b 45 08             	mov    0x8(%ebp),%eax
  8027a4:	e8 28 ff ff ff       	call   8026d1 <fd2sockid>
  8027a9:	85 c0                	test   %eax,%eax
  8027ab:	78 1f                	js     8027cc <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  8027ad:	8b 55 10             	mov    0x10(%ebp),%edx
  8027b0:	89 54 24 08          	mov    %edx,0x8(%esp)
  8027b4:	8b 55 0c             	mov    0xc(%ebp),%edx
  8027b7:	89 54 24 04          	mov    %edx,0x4(%esp)
  8027bb:	89 04 24             	mov    %eax,(%esp)
  8027be:	e8 5b 02 00 00       	call   802a1e <nsipc_accept>
  8027c3:	85 c0                	test   %eax,%eax
  8027c5:	78 05                	js     8027cc <accept+0x31>
		return r;
	return alloc_sockfd(r);
  8027c7:	e8 62 fe ff ff       	call   80262e <alloc_sockfd>
}
  8027cc:	c9                   	leave  
  8027cd:	8d 76 00             	lea    0x0(%esi),%esi
  8027d0:	c3                   	ret    
	...

008027e0 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  8027e0:	55                   	push   %ebp
  8027e1:	89 e5                	mov    %esp,%ebp
  8027e3:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  8027e6:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  8027ec:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  8027f3:	00 
  8027f4:	c7 44 24 08 00 60 80 	movl   $0x806000,0x8(%esp)
  8027fb:	00 
  8027fc:	89 44 24 04          	mov    %eax,0x4(%esp)
  802800:	89 14 24             	mov    %edx,(%esp)
  802803:	e8 08 09 00 00       	call   803110 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  802808:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80280f:	00 
  802810:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  802817:	00 
  802818:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80281b:	89 04 24             	mov    %eax,(%esp)
  80281e:	e8 5f 09 00 00       	call   803182 <ipc_recv>
    return r;
}
  802823:	c9                   	leave  
  802824:	c3                   	ret    

00802825 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  802825:	55                   	push   %ebp
  802826:	89 e5                	mov    %esp,%ebp
  802828:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  80282b:	8b 45 08             	mov    0x8(%ebp),%eax
  80282e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.socket.req_type = type;
  802833:	8b 45 0c             	mov    0xc(%ebp),%eax
  802836:	a3 04 60 80 00       	mov    %eax,0x806004
	nsipcbuf.socket.req_protocol = protocol;
  80283b:	8b 45 10             	mov    0x10(%ebp),%eax
  80283e:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SOCKET);
  802843:	b8 09 00 00 00       	mov    $0x9,%eax
  802848:	e8 93 ff ff ff       	call   8027e0 <nsipc>
}
  80284d:	c9                   	leave  
  80284e:	c3                   	ret    

0080284f <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  80284f:	55                   	push   %ebp
  802850:	89 e5                	mov    %esp,%ebp
  802852:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  802855:	8b 45 08             	mov    0x8(%ebp),%eax
  802858:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.listen.req_backlog = backlog;
  80285d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802860:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_LISTEN);
  802865:	b8 06 00 00 00       	mov    $0x6,%eax
  80286a:	e8 71 ff ff ff       	call   8027e0 <nsipc>
}
  80286f:	c9                   	leave  
  802870:	c3                   	ret    

00802871 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  802871:	55                   	push   %ebp
  802872:	89 e5                	mov    %esp,%ebp
  802874:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  802877:	8b 45 08             	mov    0x8(%ebp),%eax
  80287a:	a3 00 60 80 00       	mov    %eax,0x806000
	return nsipc(NSREQ_CLOSE);
  80287f:	b8 04 00 00 00       	mov    $0x4,%eax
  802884:	e8 57 ff ff ff       	call   8027e0 <nsipc>
}
  802889:	c9                   	leave  
  80288a:	c3                   	ret    

0080288b <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  80288b:	55                   	push   %ebp
  80288c:	89 e5                	mov    %esp,%ebp
  80288e:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  802891:	8b 45 08             	mov    0x8(%ebp),%eax
  802894:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.shutdown.req_how = how;
  802899:	8b 45 0c             	mov    0xc(%ebp),%eax
  80289c:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_SHUTDOWN);
  8028a1:	b8 03 00 00 00       	mov    $0x3,%eax
  8028a6:	e8 35 ff ff ff       	call   8027e0 <nsipc>
}
  8028ab:	c9                   	leave  
  8028ac:	c3                   	ret    

008028ad <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  8028ad:	55                   	push   %ebp
  8028ae:	89 e5                	mov    %esp,%ebp
  8028b0:	53                   	push   %ebx
  8028b1:	83 ec 14             	sub    $0x14,%esp
  8028b4:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  8028b7:	8b 45 08             	mov    0x8(%ebp),%eax
  8028ba:	a3 00 60 80 00       	mov    %eax,0x806000
	assert(size < 1600);
  8028bf:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  8028c5:	7e 24                	jle    8028eb <nsipc_send+0x3e>
  8028c7:	c7 44 24 0c 1e 3c 80 	movl   $0x803c1e,0xc(%esp)
  8028ce:	00 
  8028cf:	c7 44 24 08 42 3b 80 	movl   $0x803b42,0x8(%esp)
  8028d6:	00 
  8028d7:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  8028de:	00 
  8028df:	c7 04 24 2a 3c 80 00 	movl   $0x803c2a,(%esp)
  8028e6:	e8 51 d9 ff ff       	call   80023c <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  8028eb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8028ef:	8b 45 0c             	mov    0xc(%ebp),%eax
  8028f2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8028f6:	c7 04 24 0c 60 80 00 	movl   $0x80600c,(%esp)
  8028fd:	e8 83 e2 ff ff       	call   800b85 <memmove>
	nsipcbuf.send.req_size = size;
  802902:	89 1d 04 60 80 00    	mov    %ebx,0x806004
	nsipcbuf.send.req_flags = flags;
  802908:	8b 45 14             	mov    0x14(%ebp),%eax
  80290b:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SEND);
  802910:	b8 08 00 00 00       	mov    $0x8,%eax
  802915:	e8 c6 fe ff ff       	call   8027e0 <nsipc>
}
  80291a:	83 c4 14             	add    $0x14,%esp
  80291d:	5b                   	pop    %ebx
  80291e:	5d                   	pop    %ebp
  80291f:	c3                   	ret    

00802920 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  802920:	55                   	push   %ebp
  802921:	89 e5                	mov    %esp,%ebp
  802923:	56                   	push   %esi
  802924:	53                   	push   %ebx
  802925:	83 ec 10             	sub    $0x10,%esp
  802928:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  80292b:	8b 45 08             	mov    0x8(%ebp),%eax
  80292e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.recv.req_len = len;
  802933:	89 35 04 60 80 00    	mov    %esi,0x806004
	nsipcbuf.recv.req_flags = flags;
  802939:	8b 45 14             	mov    0x14(%ebp),%eax
  80293c:	a3 08 60 80 00       	mov    %eax,0x806008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  802941:	b8 07 00 00 00       	mov    $0x7,%eax
  802946:	e8 95 fe ff ff       	call   8027e0 <nsipc>
  80294b:	89 c3                	mov    %eax,%ebx
  80294d:	85 c0                	test   %eax,%eax
  80294f:	78 46                	js     802997 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  802951:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  802956:	7f 04                	jg     80295c <nsipc_recv+0x3c>
  802958:	39 c6                	cmp    %eax,%esi
  80295a:	7d 24                	jge    802980 <nsipc_recv+0x60>
  80295c:	c7 44 24 0c 36 3c 80 	movl   $0x803c36,0xc(%esp)
  802963:	00 
  802964:	c7 44 24 08 42 3b 80 	movl   $0x803b42,0x8(%esp)
  80296b:	00 
  80296c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  802973:	00 
  802974:	c7 04 24 2a 3c 80 00 	movl   $0x803c2a,(%esp)
  80297b:	e8 bc d8 ff ff       	call   80023c <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  802980:	89 44 24 08          	mov    %eax,0x8(%esp)
  802984:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  80298b:	00 
  80298c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80298f:	89 04 24             	mov    %eax,(%esp)
  802992:	e8 ee e1 ff ff       	call   800b85 <memmove>
	}

	return r;
}
  802997:	89 d8                	mov    %ebx,%eax
  802999:	83 c4 10             	add    $0x10,%esp
  80299c:	5b                   	pop    %ebx
  80299d:	5e                   	pop    %esi
  80299e:	5d                   	pop    %ebp
  80299f:	c3                   	ret    

008029a0 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  8029a0:	55                   	push   %ebp
  8029a1:	89 e5                	mov    %esp,%ebp
  8029a3:	53                   	push   %ebx
  8029a4:	83 ec 14             	sub    $0x14,%esp
  8029a7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  8029aa:	8b 45 08             	mov    0x8(%ebp),%eax
  8029ad:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  8029b2:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8029b6:	8b 45 0c             	mov    0xc(%ebp),%eax
  8029b9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8029bd:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  8029c4:	e8 bc e1 ff ff       	call   800b85 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  8029c9:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_CONNECT);
  8029cf:	b8 05 00 00 00       	mov    $0x5,%eax
  8029d4:	e8 07 fe ff ff       	call   8027e0 <nsipc>
}
  8029d9:	83 c4 14             	add    $0x14,%esp
  8029dc:	5b                   	pop    %ebx
  8029dd:	5d                   	pop    %ebp
  8029de:	c3                   	ret    

008029df <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  8029df:	55                   	push   %ebp
  8029e0:	89 e5                	mov    %esp,%ebp
  8029e2:	53                   	push   %ebx
  8029e3:	83 ec 14             	sub    $0x14,%esp
  8029e6:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  8029e9:	8b 45 08             	mov    0x8(%ebp),%eax
  8029ec:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  8029f1:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8029f5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8029f8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8029fc:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  802a03:	e8 7d e1 ff ff       	call   800b85 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  802a08:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_BIND);
  802a0e:	b8 02 00 00 00       	mov    $0x2,%eax
  802a13:	e8 c8 fd ff ff       	call   8027e0 <nsipc>
}
  802a18:	83 c4 14             	add    $0x14,%esp
  802a1b:	5b                   	pop    %ebx
  802a1c:	5d                   	pop    %ebp
  802a1d:	c3                   	ret    

00802a1e <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  802a1e:	55                   	push   %ebp
  802a1f:	89 e5                	mov    %esp,%ebp
  802a21:	83 ec 18             	sub    $0x18,%esp
  802a24:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802a27:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  802a2a:	8b 45 08             	mov    0x8(%ebp),%eax
  802a2d:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  802a32:	b8 01 00 00 00       	mov    $0x1,%eax
  802a37:	e8 a4 fd ff ff       	call   8027e0 <nsipc>
  802a3c:	89 c3                	mov    %eax,%ebx
  802a3e:	85 c0                	test   %eax,%eax
  802a40:	78 25                	js     802a67 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  802a42:	be 10 60 80 00       	mov    $0x806010,%esi
  802a47:	8b 06                	mov    (%esi),%eax
  802a49:	89 44 24 08          	mov    %eax,0x8(%esp)
  802a4d:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  802a54:	00 
  802a55:	8b 45 0c             	mov    0xc(%ebp),%eax
  802a58:	89 04 24             	mov    %eax,(%esp)
  802a5b:	e8 25 e1 ff ff       	call   800b85 <memmove>
		*addrlen = ret->ret_addrlen;
  802a60:	8b 16                	mov    (%esi),%edx
  802a62:	8b 45 10             	mov    0x10(%ebp),%eax
  802a65:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  802a67:	89 d8                	mov    %ebx,%eax
  802a69:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  802a6c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802a6f:	89 ec                	mov    %ebp,%esp
  802a71:	5d                   	pop    %ebp
  802a72:	c3                   	ret    
	...

00802a80 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  802a80:	55                   	push   %ebp
  802a81:	89 e5                	mov    %esp,%ebp
  802a83:	83 ec 18             	sub    $0x18,%esp
  802a86:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802a89:	89 75 fc             	mov    %esi,-0x4(%ebp)
  802a8c:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  802a8f:	8b 45 08             	mov    0x8(%ebp),%eax
  802a92:	89 04 24             	mov    %eax,(%esp)
  802a95:	e8 c6 eb ff ff       	call   801660 <fd2data>
  802a9a:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  802a9c:	c7 44 24 04 4b 3c 80 	movl   $0x803c4b,0x4(%esp)
  802aa3:	00 
  802aa4:	89 34 24             	mov    %esi,(%esp)
  802aa7:	e8 1e df ff ff       	call   8009ca <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  802aac:	8b 43 04             	mov    0x4(%ebx),%eax
  802aaf:	2b 03                	sub    (%ebx),%eax
  802ab1:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  802ab7:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  802abe:	00 00 00 
	stat->st_dev = &devpipe;
  802ac1:	c7 86 88 00 00 00 44 	movl   $0x807044,0x88(%esi)
  802ac8:	70 80 00 
	return 0;
}
  802acb:	b8 00 00 00 00       	mov    $0x0,%eax
  802ad0:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  802ad3:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802ad6:	89 ec                	mov    %ebp,%esp
  802ad8:	5d                   	pop    %ebp
  802ad9:	c3                   	ret    

00802ada <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  802ada:	55                   	push   %ebp
  802adb:	89 e5                	mov    %esp,%ebp
  802add:	53                   	push   %ebx
  802ade:	83 ec 14             	sub    $0x14,%esp
  802ae1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  802ae4:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802ae8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802aef:	e8 76 e5 ff ff       	call   80106a <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  802af4:	89 1c 24             	mov    %ebx,(%esp)
  802af7:	e8 64 eb ff ff       	call   801660 <fd2data>
  802afc:	89 44 24 04          	mov    %eax,0x4(%esp)
  802b00:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802b07:	e8 5e e5 ff ff       	call   80106a <sys_page_unmap>
}
  802b0c:	83 c4 14             	add    $0x14,%esp
  802b0f:	5b                   	pop    %ebx
  802b10:	5d                   	pop    %ebp
  802b11:	c3                   	ret    

00802b12 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  802b12:	55                   	push   %ebp
  802b13:	89 e5                	mov    %esp,%ebp
  802b15:	57                   	push   %edi
  802b16:	56                   	push   %esi
  802b17:	53                   	push   %ebx
  802b18:	83 ec 2c             	sub    $0x2c,%esp
  802b1b:	89 c7                	mov    %eax,%edi
  802b1d:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  802b20:	a1 7c 70 80 00       	mov    0x80707c,%eax
  802b25:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  802b28:	89 3c 24             	mov    %edi,(%esp)
  802b2b:	e8 a4 06 00 00       	call   8031d4 <pageref>
  802b30:	89 c6                	mov    %eax,%esi
  802b32:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802b35:	89 04 24             	mov    %eax,(%esp)
  802b38:	e8 97 06 00 00       	call   8031d4 <pageref>
  802b3d:	39 c6                	cmp    %eax,%esi
  802b3f:	0f 94 c0             	sete   %al
  802b42:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  802b45:	8b 15 7c 70 80 00    	mov    0x80707c,%edx
  802b4b:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  802b4e:	39 cb                	cmp    %ecx,%ebx
  802b50:	75 08                	jne    802b5a <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  802b52:	83 c4 2c             	add    $0x2c,%esp
  802b55:	5b                   	pop    %ebx
  802b56:	5e                   	pop    %esi
  802b57:	5f                   	pop    %edi
  802b58:	5d                   	pop    %ebp
  802b59:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  802b5a:	83 f8 01             	cmp    $0x1,%eax
  802b5d:	75 c1                	jne    802b20 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  802b5f:	8b 52 58             	mov    0x58(%edx),%edx
  802b62:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802b66:	89 54 24 08          	mov    %edx,0x8(%esp)
  802b6a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802b6e:	c7 04 24 52 3c 80 00 	movl   $0x803c52,(%esp)
  802b75:	e8 87 d7 ff ff       	call   800301 <cprintf>
  802b7a:	eb a4                	jmp    802b20 <_pipeisclosed+0xe>

00802b7c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  802b7c:	55                   	push   %ebp
  802b7d:	89 e5                	mov    %esp,%ebp
  802b7f:	57                   	push   %edi
  802b80:	56                   	push   %esi
  802b81:	53                   	push   %ebx
  802b82:	83 ec 1c             	sub    $0x1c,%esp
  802b85:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  802b88:	89 34 24             	mov    %esi,(%esp)
  802b8b:	e8 d0 ea ff ff       	call   801660 <fd2data>
  802b90:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802b92:	bf 00 00 00 00       	mov    $0x0,%edi
  802b97:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802b9b:	75 54                	jne    802bf1 <devpipe_write+0x75>
  802b9d:	eb 60                	jmp    802bff <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  802b9f:	89 da                	mov    %ebx,%edx
  802ba1:	89 f0                	mov    %esi,%eax
  802ba3:	e8 6a ff ff ff       	call   802b12 <_pipeisclosed>
  802ba8:	85 c0                	test   %eax,%eax
  802baa:	74 07                	je     802bb3 <devpipe_write+0x37>
  802bac:	b8 00 00 00 00       	mov    $0x0,%eax
  802bb1:	eb 53                	jmp    802c06 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  802bb3:	90                   	nop
  802bb4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802bb8:	e8 c8 e5 ff ff       	call   801185 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  802bbd:	8b 43 04             	mov    0x4(%ebx),%eax
  802bc0:	8b 13                	mov    (%ebx),%edx
  802bc2:	83 c2 20             	add    $0x20,%edx
  802bc5:	39 d0                	cmp    %edx,%eax
  802bc7:	73 d6                	jae    802b9f <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  802bc9:	89 c2                	mov    %eax,%edx
  802bcb:	c1 fa 1f             	sar    $0x1f,%edx
  802bce:	c1 ea 1b             	shr    $0x1b,%edx
  802bd1:	01 d0                	add    %edx,%eax
  802bd3:	83 e0 1f             	and    $0x1f,%eax
  802bd6:	29 d0                	sub    %edx,%eax
  802bd8:	89 c2                	mov    %eax,%edx
  802bda:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  802bdd:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  802be1:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  802be5:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802be9:	83 c7 01             	add    $0x1,%edi
  802bec:	39 7d 10             	cmp    %edi,0x10(%ebp)
  802bef:	76 13                	jbe    802c04 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  802bf1:	8b 43 04             	mov    0x4(%ebx),%eax
  802bf4:	8b 13                	mov    (%ebx),%edx
  802bf6:	83 c2 20             	add    $0x20,%edx
  802bf9:	39 d0                	cmp    %edx,%eax
  802bfb:	73 a2                	jae    802b9f <devpipe_write+0x23>
  802bfd:	eb ca                	jmp    802bc9 <devpipe_write+0x4d>
  802bff:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  802c04:	89 f8                	mov    %edi,%eax
}
  802c06:	83 c4 1c             	add    $0x1c,%esp
  802c09:	5b                   	pop    %ebx
  802c0a:	5e                   	pop    %esi
  802c0b:	5f                   	pop    %edi
  802c0c:	5d                   	pop    %ebp
  802c0d:	c3                   	ret    

00802c0e <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  802c0e:	55                   	push   %ebp
  802c0f:	89 e5                	mov    %esp,%ebp
  802c11:	83 ec 28             	sub    $0x28,%esp
  802c14:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802c17:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802c1a:	89 7d fc             	mov    %edi,-0x4(%ebp)
  802c1d:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  802c20:	89 3c 24             	mov    %edi,(%esp)
  802c23:	e8 38 ea ff ff       	call   801660 <fd2data>
  802c28:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802c2a:	be 00 00 00 00       	mov    $0x0,%esi
  802c2f:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802c33:	75 4c                	jne    802c81 <devpipe_read+0x73>
  802c35:	eb 5b                	jmp    802c92 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  802c37:	89 f0                	mov    %esi,%eax
  802c39:	eb 5e                	jmp    802c99 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  802c3b:	89 da                	mov    %ebx,%edx
  802c3d:	89 f8                	mov    %edi,%eax
  802c3f:	90                   	nop
  802c40:	e8 cd fe ff ff       	call   802b12 <_pipeisclosed>
  802c45:	85 c0                	test   %eax,%eax
  802c47:	74 07                	je     802c50 <devpipe_read+0x42>
  802c49:	b8 00 00 00 00       	mov    $0x0,%eax
  802c4e:	eb 49                	jmp    802c99 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  802c50:	e8 30 e5 ff ff       	call   801185 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  802c55:	8b 03                	mov    (%ebx),%eax
  802c57:	3b 43 04             	cmp    0x4(%ebx),%eax
  802c5a:	74 df                	je     802c3b <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  802c5c:	89 c2                	mov    %eax,%edx
  802c5e:	c1 fa 1f             	sar    $0x1f,%edx
  802c61:	c1 ea 1b             	shr    $0x1b,%edx
  802c64:	01 d0                	add    %edx,%eax
  802c66:	83 e0 1f             	and    $0x1f,%eax
  802c69:	29 d0                	sub    %edx,%eax
  802c6b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  802c70:	8b 55 0c             	mov    0xc(%ebp),%edx
  802c73:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  802c76:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802c79:	83 c6 01             	add    $0x1,%esi
  802c7c:	39 75 10             	cmp    %esi,0x10(%ebp)
  802c7f:	76 16                	jbe    802c97 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  802c81:	8b 03                	mov    (%ebx),%eax
  802c83:	3b 43 04             	cmp    0x4(%ebx),%eax
  802c86:	75 d4                	jne    802c5c <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  802c88:	85 f6                	test   %esi,%esi
  802c8a:	75 ab                	jne    802c37 <devpipe_read+0x29>
  802c8c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802c90:	eb a9                	jmp    802c3b <devpipe_read+0x2d>
  802c92:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  802c97:	89 f0                	mov    %esi,%eax
}
  802c99:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802c9c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802c9f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802ca2:	89 ec                	mov    %ebp,%esp
  802ca4:	5d                   	pop    %ebp
  802ca5:	c3                   	ret    

00802ca6 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  802ca6:	55                   	push   %ebp
  802ca7:	89 e5                	mov    %esp,%ebp
  802ca9:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802cac:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802caf:	89 44 24 04          	mov    %eax,0x4(%esp)
  802cb3:	8b 45 08             	mov    0x8(%ebp),%eax
  802cb6:	89 04 24             	mov    %eax,(%esp)
  802cb9:	e8 2f ea ff ff       	call   8016ed <fd_lookup>
  802cbe:	85 c0                	test   %eax,%eax
  802cc0:	78 15                	js     802cd7 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  802cc2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802cc5:	89 04 24             	mov    %eax,(%esp)
  802cc8:	e8 93 e9 ff ff       	call   801660 <fd2data>
	return _pipeisclosed(fd, p);
  802ccd:	89 c2                	mov    %eax,%edx
  802ccf:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802cd2:	e8 3b fe ff ff       	call   802b12 <_pipeisclosed>
}
  802cd7:	c9                   	leave  
  802cd8:	c3                   	ret    

00802cd9 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  802cd9:	55                   	push   %ebp
  802cda:	89 e5                	mov    %esp,%ebp
  802cdc:	83 ec 48             	sub    $0x48,%esp
  802cdf:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802ce2:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802ce5:	89 7d fc             	mov    %edi,-0x4(%ebp)
  802ce8:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  802ceb:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  802cee:	89 04 24             	mov    %eax,(%esp)
  802cf1:	e8 85 e9 ff ff       	call   80167b <fd_alloc>
  802cf6:	89 c3                	mov    %eax,%ebx
  802cf8:	85 c0                	test   %eax,%eax
  802cfa:	0f 88 42 01 00 00    	js     802e42 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802d00:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802d07:	00 
  802d08:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802d0b:	89 44 24 04          	mov    %eax,0x4(%esp)
  802d0f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802d16:	e8 0b e4 ff ff       	call   801126 <sys_page_alloc>
  802d1b:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  802d1d:	85 c0                	test   %eax,%eax
  802d1f:	0f 88 1d 01 00 00    	js     802e42 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802d25:	8d 45 e0             	lea    -0x20(%ebp),%eax
  802d28:	89 04 24             	mov    %eax,(%esp)
  802d2b:	e8 4b e9 ff ff       	call   80167b <fd_alloc>
  802d30:	89 c3                	mov    %eax,%ebx
  802d32:	85 c0                	test   %eax,%eax
  802d34:	0f 88 f5 00 00 00    	js     802e2f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802d3a:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802d41:	00 
  802d42:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802d45:	89 44 24 04          	mov    %eax,0x4(%esp)
  802d49:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802d50:	e8 d1 e3 ff ff       	call   801126 <sys_page_alloc>
  802d55:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802d57:	85 c0                	test   %eax,%eax
  802d59:	0f 88 d0 00 00 00    	js     802e2f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  802d5f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802d62:	89 04 24             	mov    %eax,(%esp)
  802d65:	e8 f6 e8 ff ff       	call   801660 <fd2data>
  802d6a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802d6c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802d73:	00 
  802d74:	89 44 24 04          	mov    %eax,0x4(%esp)
  802d78:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802d7f:	e8 a2 e3 ff ff       	call   801126 <sys_page_alloc>
  802d84:	89 c3                	mov    %eax,%ebx
  802d86:	85 c0                	test   %eax,%eax
  802d88:	0f 88 8e 00 00 00    	js     802e1c <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802d8e:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802d91:	89 04 24             	mov    %eax,(%esp)
  802d94:	e8 c7 e8 ff ff       	call   801660 <fd2data>
  802d99:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  802da0:	00 
  802da1:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802da5:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  802dac:	00 
  802dad:	89 74 24 04          	mov    %esi,0x4(%esp)
  802db1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802db8:	e8 0b e3 ff ff       	call   8010c8 <sys_page_map>
  802dbd:	89 c3                	mov    %eax,%ebx
  802dbf:	85 c0                	test   %eax,%eax
  802dc1:	78 49                	js     802e0c <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  802dc3:	b8 44 70 80 00       	mov    $0x807044,%eax
  802dc8:	8b 08                	mov    (%eax),%ecx
  802dca:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  802dcd:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  802dcf:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  802dd2:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  802dd9:	8b 10                	mov    (%eax),%edx
  802ddb:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802dde:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  802de0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802de3:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  802dea:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802ded:	89 04 24             	mov    %eax,(%esp)
  802df0:	e8 5b e8 ff ff       	call   801650 <fd2num>
  802df5:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  802df7:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802dfa:	89 04 24             	mov    %eax,(%esp)
  802dfd:	e8 4e e8 ff ff       	call   801650 <fd2num>
  802e02:	89 47 04             	mov    %eax,0x4(%edi)
  802e05:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  802e0a:	eb 36                	jmp    802e42 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  802e0c:	89 74 24 04          	mov    %esi,0x4(%esp)
  802e10:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802e17:	e8 4e e2 ff ff       	call   80106a <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  802e1c:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802e1f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802e23:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802e2a:	e8 3b e2 ff ff       	call   80106a <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  802e2f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802e32:	89 44 24 04          	mov    %eax,0x4(%esp)
  802e36:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802e3d:	e8 28 e2 ff ff       	call   80106a <sys_page_unmap>
    err:
	return r;
}
  802e42:	89 d8                	mov    %ebx,%eax
  802e44:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802e47:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802e4a:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802e4d:	89 ec                	mov    %ebp,%esp
  802e4f:	5d                   	pop    %ebp
  802e50:	c3                   	ret    
  802e51:	00 00                	add    %al,(%eax)
	...

00802e54 <wait>:
#include <inc/lib.h>

// Waits until 'envid' exits.
void
wait(envid_t envid)
{
  802e54:	55                   	push   %ebp
  802e55:	89 e5                	mov    %esp,%ebp
  802e57:	56                   	push   %esi
  802e58:	53                   	push   %ebx
  802e59:	83 ec 10             	sub    $0x10,%esp
  802e5c:	8b 45 08             	mov    0x8(%ebp),%eax
	volatile struct Env *e;

	assert(envid != 0);
  802e5f:	85 c0                	test   %eax,%eax
  802e61:	75 24                	jne    802e87 <wait+0x33>
  802e63:	c7 44 24 0c 6a 3c 80 	movl   $0x803c6a,0xc(%esp)
  802e6a:	00 
  802e6b:	c7 44 24 08 42 3b 80 	movl   $0x803b42,0x8(%esp)
  802e72:	00 
  802e73:	c7 44 24 04 09 00 00 	movl   $0x9,0x4(%esp)
  802e7a:	00 
  802e7b:	c7 04 24 75 3c 80 00 	movl   $0x803c75,(%esp)
  802e82:	e8 b5 d3 ff ff       	call   80023c <_panic>
	e = &envs[ENVX(envid)];
  802e87:	89 c3                	mov    %eax,%ebx
  802e89:	81 e3 ff 03 00 00    	and    $0x3ff,%ebx
  802e8f:	6b db 7c             	imul   $0x7c,%ebx,%ebx
  802e92:	81 c3 00 00 c0 ee    	add    $0xeec00000,%ebx
	while (e->env_id == envid && e->env_status != ENV_FREE)
  802e98:	8b 73 4c             	mov    0x4c(%ebx),%esi
  802e9b:	39 c6                	cmp    %eax,%esi
  802e9d:	75 1a                	jne    802eb9 <wait+0x65>
  802e9f:	8b 43 54             	mov    0x54(%ebx),%eax
  802ea2:	85 c0                	test   %eax,%eax
  802ea4:	74 13                	je     802eb9 <wait+0x65>
		sys_yield();
  802ea6:	e8 da e2 ff ff       	call   801185 <sys_yield>
{
	volatile struct Env *e;

	assert(envid != 0);
	e = &envs[ENVX(envid)];
	while (e->env_id == envid && e->env_status != ENV_FREE)
  802eab:	8b 43 4c             	mov    0x4c(%ebx),%eax
  802eae:	39 f0                	cmp    %esi,%eax
  802eb0:	75 07                	jne    802eb9 <wait+0x65>
  802eb2:	8b 43 54             	mov    0x54(%ebx),%eax
  802eb5:	85 c0                	test   %eax,%eax
  802eb7:	75 ed                	jne    802ea6 <wait+0x52>
		sys_yield();
}
  802eb9:	83 c4 10             	add    $0x10,%esp
  802ebc:	5b                   	pop    %ebx
  802ebd:	5e                   	pop    %esi
  802ebe:	5d                   	pop    %ebp
  802ebf:	c3                   	ret    

00802ec0 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  802ec0:	55                   	push   %ebp
  802ec1:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  802ec3:	b8 00 00 00 00       	mov    $0x0,%eax
  802ec8:	5d                   	pop    %ebp
  802ec9:	c3                   	ret    

00802eca <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  802eca:	55                   	push   %ebp
  802ecb:	89 e5                	mov    %esp,%ebp
  802ecd:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  802ed0:	c7 44 24 04 80 3c 80 	movl   $0x803c80,0x4(%esp)
  802ed7:	00 
  802ed8:	8b 45 0c             	mov    0xc(%ebp),%eax
  802edb:	89 04 24             	mov    %eax,(%esp)
  802ede:	e8 e7 da ff ff       	call   8009ca <strcpy>
	return 0;
}
  802ee3:	b8 00 00 00 00       	mov    $0x0,%eax
  802ee8:	c9                   	leave  
  802ee9:	c3                   	ret    

00802eea <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  802eea:	55                   	push   %ebp
  802eeb:	89 e5                	mov    %esp,%ebp
  802eed:	57                   	push   %edi
  802eee:	56                   	push   %esi
  802eef:	53                   	push   %ebx
  802ef0:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802ef6:	b8 00 00 00 00       	mov    $0x0,%eax
  802efb:	be 00 00 00 00       	mov    $0x0,%esi
  802f00:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802f04:	74 41                	je     802f47 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802f06:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  802f0c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  802f0f:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  802f11:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  802f17:	ba 7f 00 00 00       	mov    $0x7f,%edx
  802f1c:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802f1f:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802f23:	03 45 0c             	add    0xc(%ebp),%eax
  802f26:	89 44 24 04          	mov    %eax,0x4(%esp)
  802f2a:	89 3c 24             	mov    %edi,(%esp)
  802f2d:	e8 53 dc ff ff       	call   800b85 <memmove>
		sys_cputs(buf, m);
  802f32:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802f36:	89 3c 24             	mov    %edi,(%esp)
  802f39:	e8 82 de ff ff       	call   800dc0 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802f3e:	01 de                	add    %ebx,%esi
  802f40:	89 f0                	mov    %esi,%eax
  802f42:	3b 75 10             	cmp    0x10(%ebp),%esi
  802f45:	72 c5                	jb     802f0c <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  802f47:	89 f0                	mov    %esi,%eax
  802f49:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  802f4f:	5b                   	pop    %ebx
  802f50:	5e                   	pop    %esi
  802f51:	5f                   	pop    %edi
  802f52:	5d                   	pop    %ebp
  802f53:	c3                   	ret    

00802f54 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  802f54:	55                   	push   %ebp
  802f55:	89 e5                	mov    %esp,%ebp
  802f57:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  802f5a:	8b 45 08             	mov    0x8(%ebp),%eax
  802f5d:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  802f60:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  802f67:	00 
  802f68:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802f6b:	89 04 24             	mov    %eax,(%esp)
  802f6e:	e8 4d de ff ff       	call   800dc0 <sys_cputs>
}
  802f73:	c9                   	leave  
  802f74:	c3                   	ret    

00802f75 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  802f75:	55                   	push   %ebp
  802f76:	89 e5                	mov    %esp,%ebp
  802f78:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  802f7b:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802f7f:	75 07                	jne    802f88 <devcons_read+0x13>
  802f81:	eb 2d                	jmp    802fb0 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  802f83:	e8 fd e1 ff ff       	call   801185 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  802f88:	90                   	nop
  802f89:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802f90:	e8 f7 dd ff ff       	call   800d8c <sys_cgetc>
  802f95:	85 c0                	test   %eax,%eax
  802f97:	74 ea                	je     802f83 <devcons_read+0xe>
  802f99:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  802f9b:	85 c0                	test   %eax,%eax
  802f9d:	78 16                	js     802fb5 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  802f9f:	83 f8 04             	cmp    $0x4,%eax
  802fa2:	74 0c                	je     802fb0 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  802fa4:	8b 45 0c             	mov    0xc(%ebp),%eax
  802fa7:	88 10                	mov    %dl,(%eax)
  802fa9:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  802fae:	eb 05                	jmp    802fb5 <devcons_read+0x40>
  802fb0:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802fb5:	c9                   	leave  
  802fb6:	c3                   	ret    

00802fb7 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  802fb7:	55                   	push   %ebp
  802fb8:	89 e5                	mov    %esp,%ebp
  802fba:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  802fbd:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802fc0:	89 04 24             	mov    %eax,(%esp)
  802fc3:	e8 b3 e6 ff ff       	call   80167b <fd_alloc>
  802fc8:	85 c0                	test   %eax,%eax
  802fca:	78 3f                	js     80300b <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  802fcc:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802fd3:	00 
  802fd4:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802fd7:	89 44 24 04          	mov    %eax,0x4(%esp)
  802fdb:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802fe2:	e8 3f e1 ff ff       	call   801126 <sys_page_alloc>
  802fe7:	85 c0                	test   %eax,%eax
  802fe9:	78 20                	js     80300b <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  802feb:	8b 15 60 70 80 00    	mov    0x807060,%edx
  802ff1:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802ff4:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  802ff6:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802ff9:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  803000:	8b 45 f4             	mov    -0xc(%ebp),%eax
  803003:	89 04 24             	mov    %eax,(%esp)
  803006:	e8 45 e6 ff ff       	call   801650 <fd2num>
}
  80300b:	c9                   	leave  
  80300c:	c3                   	ret    

0080300d <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  80300d:	55                   	push   %ebp
  80300e:	89 e5                	mov    %esp,%ebp
  803010:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  803013:	8d 45 f4             	lea    -0xc(%ebp),%eax
  803016:	89 44 24 04          	mov    %eax,0x4(%esp)
  80301a:	8b 45 08             	mov    0x8(%ebp),%eax
  80301d:	89 04 24             	mov    %eax,(%esp)
  803020:	e8 c8 e6 ff ff       	call   8016ed <fd_lookup>
  803025:	85 c0                	test   %eax,%eax
  803027:	78 11                	js     80303a <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  803029:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80302c:	8b 00                	mov    (%eax),%eax
  80302e:	3b 05 60 70 80 00    	cmp    0x807060,%eax
  803034:	0f 94 c0             	sete   %al
  803037:	0f b6 c0             	movzbl %al,%eax
}
  80303a:	c9                   	leave  
  80303b:	c3                   	ret    

0080303c <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  80303c:	55                   	push   %ebp
  80303d:	89 e5                	mov    %esp,%ebp
  80303f:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  803042:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  803049:	00 
  80304a:	8d 45 f7             	lea    -0x9(%ebp),%eax
  80304d:	89 44 24 04          	mov    %eax,0x4(%esp)
  803051:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  803058:	e8 f6 e8 ff ff       	call   801953 <read>
	if (r < 0)
  80305d:	85 c0                	test   %eax,%eax
  80305f:	78 0f                	js     803070 <getchar+0x34>
		return r;
	if (r < 1)
  803061:	85 c0                	test   %eax,%eax
  803063:	7f 07                	jg     80306c <getchar+0x30>
  803065:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  80306a:	eb 04                	jmp    803070 <getchar+0x34>
		return -E_EOF;
	return c;
  80306c:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  803070:	c9                   	leave  
  803071:	c3                   	ret    
	...

00803074 <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  803074:	55                   	push   %ebp
  803075:	89 e5                	mov    %esp,%ebp
  803077:	83 ec 18             	sub    $0x18,%esp
	int r;

	if (_pgfault_handler == NULL) {
  80307a:	83 3d 84 70 80 00 00 	cmpl   $0x0,0x807084
  803081:	75 55                	jne    8030d8 <set_pgfault_handler+0x64>
		// First time through!
		// LAB 4: Your code here.
        if (sys_page_alloc(sys_getenvid(), (void *)(UXSTACKTOP-PGSIZE), PTE_P|PTE_U|PTE_W))
  803083:	e8 31 e1 ff ff       	call   8011b9 <sys_getenvid>
  803088:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  80308f:	00 
  803090:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  803097:	ee 
  803098:	89 04 24             	mov    %eax,(%esp)
  80309b:	e8 86 e0 ff ff       	call   801126 <sys_page_alloc>
  8030a0:	85 c0                	test   %eax,%eax
  8030a2:	74 1c                	je     8030c0 <set_pgfault_handler+0x4c>
		    panic("set_pgfault_handler not implemented");
  8030a4:	c7 44 24 08 8c 3c 80 	movl   $0x803c8c,0x8(%esp)
  8030ab:	00 
  8030ac:	c7 44 24 04 21 00 00 	movl   $0x21,0x4(%esp)
  8030b3:	00 
  8030b4:	c7 04 24 b0 3c 80 00 	movl   $0x803cb0,(%esp)
  8030bb:	e8 7c d1 ff ff       	call   80023c <_panic>
        sys_env_set_pgfault_upcall(env->env_id, _pgfault_upcall);
  8030c0:	a1 7c 70 80 00       	mov    0x80707c,%eax
  8030c5:	8b 40 4c             	mov    0x4c(%eax),%eax
  8030c8:	c7 44 24 04 e4 30 80 	movl   $0x8030e4,0x4(%esp)
  8030cf:	00 
  8030d0:	89 04 24             	mov    %eax,(%esp)
  8030d3:	e8 78 de ff ff       	call   800f50 <sys_env_set_pgfault_upcall>
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  8030d8:	8b 45 08             	mov    0x8(%ebp),%eax
  8030db:	a3 84 70 80 00       	mov    %eax,0x807084
}
  8030e0:	c9                   	leave  
  8030e1:	c3                   	ret    
	...

008030e4 <_pgfault_upcall>:

.text
.globl _pgfault_upcall
_pgfault_upcall:
	// Call the C page fault handler.
	pushl %esp			// function argument: pointer to UTF
  8030e4:	54                   	push   %esp
	movl _pgfault_handler, %eax
  8030e5:	a1 84 70 80 00       	mov    0x807084,%eax
	call *%eax
  8030ea:	ff d0                	call   *%eax
	addl $4, %esp			// pop function argument
  8030ec:	83 c4 04             	add    $0x4,%esp
	// may find that you have to rearrange your code in non-obvious
	// ways as registers become unavailable as scratch space.
	//
	// LAB 4: Your code here.

    subl $4, 48(%esp)
  8030ef:	83 6c 24 30 04       	subl   $0x4,0x30(%esp)
    movl 48(%esp), %eax
  8030f4:	8b 44 24 30          	mov    0x30(%esp),%eax
    movl 40(%esp), %ebx
  8030f8:	8b 5c 24 28          	mov    0x28(%esp),%ebx
    movl %ebx, (%eax)
  8030fc:	89 18                	mov    %ebx,(%eax)
    
	// Restore the trap-time registers.  After you do this, you
	// can no longer modify any general-purpose registers.
	// LAB 4: Your code here.
    addl $8, %esp
  8030fe:	83 c4 08             	add    $0x8,%esp
    popal
  803101:	61                   	popa   
   
	// Restore eflags from the stack.  After you do this, you can
	// no longer use arithmetic operations or anything else that
	// modifies eflags.
	// LAB 4: Your code here.
    pushl 4(%esp)
  803102:	ff 74 24 04          	pushl  0x4(%esp)
    popf
  803106:	9d                   	popf   

	// Switch back to the adjusted trap-time stack.
	// LAB 4: Your code here.
    movl 8(%esp), %esp
  803107:	8b 64 24 08          	mov    0x8(%esp),%esp

	// Return to re-execute the instruction that faulted.
	// LAB 4: Your code here.
    ret
  80310b:	c3                   	ret    
  80310c:	00 00                	add    %al,(%eax)
	...

00803110 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  803110:	55                   	push   %ebp
  803111:	89 e5                	mov    %esp,%ebp
  803113:	57                   	push   %edi
  803114:	56                   	push   %esi
  803115:	53                   	push   %ebx
  803116:	83 ec 2c             	sub    $0x2c,%esp
  803119:	8b 75 08             	mov    0x8(%ebp),%esi
  80311c:	8b 7d 0c             	mov    0xc(%ebp),%edi
  80311f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  803122:	85 db                	test   %ebx,%ebx
  803124:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  803129:	0f 45 c3             	cmovne %ebx,%eax
  80312c:	8b 55 14             	mov    0x14(%ebp),%edx
  80312f:	89 54 24 0c          	mov    %edx,0xc(%esp)
  803133:	89 44 24 08          	mov    %eax,0x8(%esp)
  803137:	89 7c 24 04          	mov    %edi,0x4(%esp)
  80313b:	89 34 24             	mov    %esi,(%esp)
  80313e:	e8 ad dd ff ff       	call   800ef0 <sys_ipc_try_send>
  803143:	83 f8 f9             	cmp    $0xfffffff9,%eax
  803146:	75 0a                	jne    803152 <ipc_send+0x42>
      sys_yield();
  803148:	e8 38 e0 ff ff       	call   801185 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  80314d:	8d 76 00             	lea    0x0(%esi),%esi
  803150:	eb d0                	jmp    803122 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  803152:	85 c0                	test   %eax,%eax
  803154:	79 24                	jns    80317a <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  803156:	89 44 24 10          	mov    %eax,0x10(%esp)
  80315a:	89 74 24 0c          	mov    %esi,0xc(%esp)
  80315e:	c7 44 24 08 c0 3c 80 	movl   $0x803cc0,0x8(%esp)
  803165:	00 
  803166:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  80316d:	00 
  80316e:	c7 04 24 e4 3c 80 00 	movl   $0x803ce4,(%esp)
  803175:	e8 c2 d0 ff ff       	call   80023c <_panic>
    else
      return;
  }
}
  80317a:	83 c4 2c             	add    $0x2c,%esp
  80317d:	5b                   	pop    %ebx
  80317e:	5e                   	pop    %esi
  80317f:	5f                   	pop    %edi
  803180:	5d                   	pop    %ebp
  803181:	c3                   	ret    

00803182 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  803182:	55                   	push   %ebp
  803183:	89 e5                	mov    %esp,%ebp
  803185:	56                   	push   %esi
  803186:	53                   	push   %ebx
  803187:	83 ec 10             	sub    $0x10,%esp
  80318a:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80318d:	8b 45 0c             	mov    0xc(%ebp),%eax
  803190:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  803193:	85 c0                	test   %eax,%eax
  803195:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  80319a:	0f 44 c2             	cmove  %edx,%eax
  80319d:	89 04 24             	mov    %eax,(%esp)
  8031a0:	e8 ee dc ff ff       	call   800e93 <sys_ipc_recv>
  8031a5:	85 c0                	test   %eax,%eax
  8031a7:	78 24                	js     8031cd <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  8031a9:	85 db                	test   %ebx,%ebx
  8031ab:	74 0a                	je     8031b7 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  8031ad:	a1 7c 70 80 00       	mov    0x80707c,%eax
  8031b2:	8b 40 74             	mov    0x74(%eax),%eax
  8031b5:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  8031b7:	85 f6                	test   %esi,%esi
  8031b9:	74 0a                	je     8031c5 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  8031bb:	a1 7c 70 80 00       	mov    0x80707c,%eax
  8031c0:	8b 40 78             	mov    0x78(%eax),%eax
  8031c3:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  8031c5:	a1 7c 70 80 00       	mov    0x80707c,%eax
  8031ca:	8b 40 70             	mov    0x70(%eax),%eax
}
  8031cd:	83 c4 10             	add    $0x10,%esp
  8031d0:	5b                   	pop    %ebx
  8031d1:	5e                   	pop    %esi
  8031d2:	5d                   	pop    %ebp
  8031d3:	c3                   	ret    

008031d4 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  8031d4:	55                   	push   %ebp
  8031d5:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  8031d7:	8b 45 08             	mov    0x8(%ebp),%eax
  8031da:	89 c2                	mov    %eax,%edx
  8031dc:	c1 ea 16             	shr    $0x16,%edx
  8031df:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  8031e6:	f6 c2 01             	test   $0x1,%dl
  8031e9:	74 26                	je     803211 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  8031eb:	c1 e8 0c             	shr    $0xc,%eax
  8031ee:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  8031f5:	a8 01                	test   $0x1,%al
  8031f7:	74 18                	je     803211 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  8031f9:	c1 e8 0c             	shr    $0xc,%eax
  8031fc:	8d 14 40             	lea    (%eax,%eax,2),%edx
  8031ff:	c1 e2 02             	shl    $0x2,%edx
  803202:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  803207:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  80320c:	0f b7 c0             	movzwl %ax,%eax
  80320f:	eb 05                	jmp    803216 <pageref+0x42>
  803211:	b8 00 00 00 00       	mov    $0x0,%eax
}
  803216:	5d                   	pop    %ebp
  803217:	c3                   	ret    
	...

00803220 <__udivdi3>:
  803220:	55                   	push   %ebp
  803221:	89 e5                	mov    %esp,%ebp
  803223:	57                   	push   %edi
  803224:	56                   	push   %esi
  803225:	83 ec 10             	sub    $0x10,%esp
  803228:	8b 45 14             	mov    0x14(%ebp),%eax
  80322b:	8b 55 08             	mov    0x8(%ebp),%edx
  80322e:	8b 75 10             	mov    0x10(%ebp),%esi
  803231:	8b 7d 0c             	mov    0xc(%ebp),%edi
  803234:	85 c0                	test   %eax,%eax
  803236:	89 55 f0             	mov    %edx,-0x10(%ebp)
  803239:	75 35                	jne    803270 <__udivdi3+0x50>
  80323b:	39 fe                	cmp    %edi,%esi
  80323d:	77 61                	ja     8032a0 <__udivdi3+0x80>
  80323f:	85 f6                	test   %esi,%esi
  803241:	75 0b                	jne    80324e <__udivdi3+0x2e>
  803243:	b8 01 00 00 00       	mov    $0x1,%eax
  803248:	31 d2                	xor    %edx,%edx
  80324a:	f7 f6                	div    %esi
  80324c:	89 c6                	mov    %eax,%esi
  80324e:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  803251:	31 d2                	xor    %edx,%edx
  803253:	89 f8                	mov    %edi,%eax
  803255:	f7 f6                	div    %esi
  803257:	89 c7                	mov    %eax,%edi
  803259:	89 c8                	mov    %ecx,%eax
  80325b:	f7 f6                	div    %esi
  80325d:	89 c1                	mov    %eax,%ecx
  80325f:	89 fa                	mov    %edi,%edx
  803261:	89 c8                	mov    %ecx,%eax
  803263:	83 c4 10             	add    $0x10,%esp
  803266:	5e                   	pop    %esi
  803267:	5f                   	pop    %edi
  803268:	5d                   	pop    %ebp
  803269:	c3                   	ret    
  80326a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  803270:	39 f8                	cmp    %edi,%eax
  803272:	77 1c                	ja     803290 <__udivdi3+0x70>
  803274:	0f bd d0             	bsr    %eax,%edx
  803277:	83 f2 1f             	xor    $0x1f,%edx
  80327a:	89 55 f4             	mov    %edx,-0xc(%ebp)
  80327d:	75 39                	jne    8032b8 <__udivdi3+0x98>
  80327f:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  803282:	0f 86 a0 00 00 00    	jbe    803328 <__udivdi3+0x108>
  803288:	39 f8                	cmp    %edi,%eax
  80328a:	0f 82 98 00 00 00    	jb     803328 <__udivdi3+0x108>
  803290:	31 ff                	xor    %edi,%edi
  803292:	31 c9                	xor    %ecx,%ecx
  803294:	89 c8                	mov    %ecx,%eax
  803296:	89 fa                	mov    %edi,%edx
  803298:	83 c4 10             	add    $0x10,%esp
  80329b:	5e                   	pop    %esi
  80329c:	5f                   	pop    %edi
  80329d:	5d                   	pop    %ebp
  80329e:	c3                   	ret    
  80329f:	90                   	nop
  8032a0:	89 d1                	mov    %edx,%ecx
  8032a2:	89 fa                	mov    %edi,%edx
  8032a4:	89 c8                	mov    %ecx,%eax
  8032a6:	31 ff                	xor    %edi,%edi
  8032a8:	f7 f6                	div    %esi
  8032aa:	89 c1                	mov    %eax,%ecx
  8032ac:	89 fa                	mov    %edi,%edx
  8032ae:	89 c8                	mov    %ecx,%eax
  8032b0:	83 c4 10             	add    $0x10,%esp
  8032b3:	5e                   	pop    %esi
  8032b4:	5f                   	pop    %edi
  8032b5:	5d                   	pop    %ebp
  8032b6:	c3                   	ret    
  8032b7:	90                   	nop
  8032b8:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8032bc:	89 f2                	mov    %esi,%edx
  8032be:	d3 e0                	shl    %cl,%eax
  8032c0:	89 45 ec             	mov    %eax,-0x14(%ebp)
  8032c3:	b8 20 00 00 00       	mov    $0x20,%eax
  8032c8:	2b 45 f4             	sub    -0xc(%ebp),%eax
  8032cb:	89 c1                	mov    %eax,%ecx
  8032cd:	d3 ea                	shr    %cl,%edx
  8032cf:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8032d3:	0b 55 ec             	or     -0x14(%ebp),%edx
  8032d6:	d3 e6                	shl    %cl,%esi
  8032d8:	89 c1                	mov    %eax,%ecx
  8032da:	89 75 e8             	mov    %esi,-0x18(%ebp)
  8032dd:	89 fe                	mov    %edi,%esi
  8032df:	d3 ee                	shr    %cl,%esi
  8032e1:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8032e5:	89 55 ec             	mov    %edx,-0x14(%ebp)
  8032e8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8032eb:	d3 e7                	shl    %cl,%edi
  8032ed:	89 c1                	mov    %eax,%ecx
  8032ef:	d3 ea                	shr    %cl,%edx
  8032f1:	09 d7                	or     %edx,%edi
  8032f3:	89 f2                	mov    %esi,%edx
  8032f5:	89 f8                	mov    %edi,%eax
  8032f7:	f7 75 ec             	divl   -0x14(%ebp)
  8032fa:	89 d6                	mov    %edx,%esi
  8032fc:	89 c7                	mov    %eax,%edi
  8032fe:	f7 65 e8             	mull   -0x18(%ebp)
  803301:	39 d6                	cmp    %edx,%esi
  803303:	89 55 ec             	mov    %edx,-0x14(%ebp)
  803306:	72 30                	jb     803338 <__udivdi3+0x118>
  803308:	8b 55 f0             	mov    -0x10(%ebp),%edx
  80330b:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  80330f:	d3 e2                	shl    %cl,%edx
  803311:	39 c2                	cmp    %eax,%edx
  803313:	73 05                	jae    80331a <__udivdi3+0xfa>
  803315:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  803318:	74 1e                	je     803338 <__udivdi3+0x118>
  80331a:	89 f9                	mov    %edi,%ecx
  80331c:	31 ff                	xor    %edi,%edi
  80331e:	e9 71 ff ff ff       	jmp    803294 <__udivdi3+0x74>
  803323:	90                   	nop
  803324:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803328:	31 ff                	xor    %edi,%edi
  80332a:	b9 01 00 00 00       	mov    $0x1,%ecx
  80332f:	e9 60 ff ff ff       	jmp    803294 <__udivdi3+0x74>
  803334:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803338:	8d 4f ff             	lea    -0x1(%edi),%ecx
  80333b:	31 ff                	xor    %edi,%edi
  80333d:	89 c8                	mov    %ecx,%eax
  80333f:	89 fa                	mov    %edi,%edx
  803341:	83 c4 10             	add    $0x10,%esp
  803344:	5e                   	pop    %esi
  803345:	5f                   	pop    %edi
  803346:	5d                   	pop    %ebp
  803347:	c3                   	ret    
	...

00803350 <__umoddi3>:
  803350:	55                   	push   %ebp
  803351:	89 e5                	mov    %esp,%ebp
  803353:	57                   	push   %edi
  803354:	56                   	push   %esi
  803355:	83 ec 20             	sub    $0x20,%esp
  803358:	8b 55 14             	mov    0x14(%ebp),%edx
  80335b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80335e:	8b 7d 10             	mov    0x10(%ebp),%edi
  803361:	8b 75 0c             	mov    0xc(%ebp),%esi
  803364:	85 d2                	test   %edx,%edx
  803366:	89 c8                	mov    %ecx,%eax
  803368:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  80336b:	75 13                	jne    803380 <__umoddi3+0x30>
  80336d:	39 f7                	cmp    %esi,%edi
  80336f:	76 3f                	jbe    8033b0 <__umoddi3+0x60>
  803371:	89 f2                	mov    %esi,%edx
  803373:	f7 f7                	div    %edi
  803375:	89 d0                	mov    %edx,%eax
  803377:	31 d2                	xor    %edx,%edx
  803379:	83 c4 20             	add    $0x20,%esp
  80337c:	5e                   	pop    %esi
  80337d:	5f                   	pop    %edi
  80337e:	5d                   	pop    %ebp
  80337f:	c3                   	ret    
  803380:	39 f2                	cmp    %esi,%edx
  803382:	77 4c                	ja     8033d0 <__umoddi3+0x80>
  803384:	0f bd ca             	bsr    %edx,%ecx
  803387:	83 f1 1f             	xor    $0x1f,%ecx
  80338a:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  80338d:	75 51                	jne    8033e0 <__umoddi3+0x90>
  80338f:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  803392:	0f 87 e0 00 00 00    	ja     803478 <__umoddi3+0x128>
  803398:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80339b:	29 f8                	sub    %edi,%eax
  80339d:	19 d6                	sbb    %edx,%esi
  80339f:	89 45 f4             	mov    %eax,-0xc(%ebp)
  8033a2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8033a5:	89 f2                	mov    %esi,%edx
  8033a7:	83 c4 20             	add    $0x20,%esp
  8033aa:	5e                   	pop    %esi
  8033ab:	5f                   	pop    %edi
  8033ac:	5d                   	pop    %ebp
  8033ad:	c3                   	ret    
  8033ae:	66 90                	xchg   %ax,%ax
  8033b0:	85 ff                	test   %edi,%edi
  8033b2:	75 0b                	jne    8033bf <__umoddi3+0x6f>
  8033b4:	b8 01 00 00 00       	mov    $0x1,%eax
  8033b9:	31 d2                	xor    %edx,%edx
  8033bb:	f7 f7                	div    %edi
  8033bd:	89 c7                	mov    %eax,%edi
  8033bf:	89 f0                	mov    %esi,%eax
  8033c1:	31 d2                	xor    %edx,%edx
  8033c3:	f7 f7                	div    %edi
  8033c5:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8033c8:	f7 f7                	div    %edi
  8033ca:	eb a9                	jmp    803375 <__umoddi3+0x25>
  8033cc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8033d0:	89 c8                	mov    %ecx,%eax
  8033d2:	89 f2                	mov    %esi,%edx
  8033d4:	83 c4 20             	add    $0x20,%esp
  8033d7:	5e                   	pop    %esi
  8033d8:	5f                   	pop    %edi
  8033d9:	5d                   	pop    %ebp
  8033da:	c3                   	ret    
  8033db:	90                   	nop
  8033dc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8033e0:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  8033e4:	d3 e2                	shl    %cl,%edx
  8033e6:	89 55 f4             	mov    %edx,-0xc(%ebp)
  8033e9:	ba 20 00 00 00       	mov    $0x20,%edx
  8033ee:	2b 55 f0             	sub    -0x10(%ebp),%edx
  8033f1:	89 55 ec             	mov    %edx,-0x14(%ebp)
  8033f4:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  8033f8:	89 fa                	mov    %edi,%edx
  8033fa:	d3 ea                	shr    %cl,%edx
  8033fc:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803400:	0b 55 f4             	or     -0xc(%ebp),%edx
  803403:	d3 e7                	shl    %cl,%edi
  803405:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803409:	89 55 f4             	mov    %edx,-0xc(%ebp)
  80340c:	89 f2                	mov    %esi,%edx
  80340e:	89 7d e8             	mov    %edi,-0x18(%ebp)
  803411:	89 c7                	mov    %eax,%edi
  803413:	d3 ea                	shr    %cl,%edx
  803415:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803419:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  80341c:	89 c2                	mov    %eax,%edx
  80341e:	d3 e6                	shl    %cl,%esi
  803420:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803424:	d3 ea                	shr    %cl,%edx
  803426:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  80342a:	09 d6                	or     %edx,%esi
  80342c:	89 f0                	mov    %esi,%eax
  80342e:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  803431:	d3 e7                	shl    %cl,%edi
  803433:	89 f2                	mov    %esi,%edx
  803435:	f7 75 f4             	divl   -0xc(%ebp)
  803438:	89 d6                	mov    %edx,%esi
  80343a:	f7 65 e8             	mull   -0x18(%ebp)
  80343d:	39 d6                	cmp    %edx,%esi
  80343f:	72 2b                	jb     80346c <__umoddi3+0x11c>
  803441:	39 c7                	cmp    %eax,%edi
  803443:	72 23                	jb     803468 <__umoddi3+0x118>
  803445:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803449:	29 c7                	sub    %eax,%edi
  80344b:	19 d6                	sbb    %edx,%esi
  80344d:	89 f0                	mov    %esi,%eax
  80344f:	89 f2                	mov    %esi,%edx
  803451:	d3 ef                	shr    %cl,%edi
  803453:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803457:	d3 e0                	shl    %cl,%eax
  803459:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  80345d:	09 f8                	or     %edi,%eax
  80345f:	d3 ea                	shr    %cl,%edx
  803461:	83 c4 20             	add    $0x20,%esp
  803464:	5e                   	pop    %esi
  803465:	5f                   	pop    %edi
  803466:	5d                   	pop    %ebp
  803467:	c3                   	ret    
  803468:	39 d6                	cmp    %edx,%esi
  80346a:	75 d9                	jne    803445 <__umoddi3+0xf5>
  80346c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  80346f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  803472:	eb d1                	jmp    803445 <__umoddi3+0xf5>
  803474:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803478:	39 f2                	cmp    %esi,%edx
  80347a:	0f 82 18 ff ff ff    	jb     803398 <__umoddi3+0x48>
  803480:	e9 1d ff ff ff       	jmp    8033a2 <__umoddi3+0x52>
